Skip to content

Removes User Quota Related Code#355

Merged
pm-McFly merged 8 commits intodevfrom
chore/remove-quota-references
Mar 31, 2026
Merged

Removes User Quota Related Code#355
pm-McFly merged 8 commits intodevfrom
chore/remove-quota-references

Conversation

@pm-McFly
Copy link
Copy Markdown
Collaborator

@pm-McFly pm-McFly commented Mar 30, 2026

What

Removal of unmaintained legacy code regarding user quotas.

Why

The user quota belonged to the age of ToM trying to be an all in one implementation of the Matrix Protocol. The later shift of this project toward only implementing the Identity API and some extended yet related features made this part of the code unmaintained and out of the scope of implementation.

How

This PR does nothing more than removing code files and implementations.

Checklist

Code

  • Tests pass (npm test)
  • Linter is clean (npm run check) -- we know it to be failing due to the amount of legacy code left on the old eslint config...
  • No new any introduced
  • No dead code or commented-out blocks
  • All other style rules per CODING_STYLE.md

Scope

  • This PR addresses one concern (not a mix of bug fixes, refactors, and features)
  • Cross-module changes are documented in the description

Documentation

  • Inline comments explain why, not what
  • Relevant docs updated if behaviour changed

Tests

  • New behaviour is covered by tests
  • If a new endpoint was added: handler integration test included
  • If a new service method was added: unit test with stubbed repo included

Git

Signed-off-by: Pierre 'McFly' Marty <pmarty@linagora.com>
Signed-off-by: Pierre 'McFly' Marty <pmarty@linagora.com>
Signed-off-by: Pierre 'McFly' Marty <pmarty@linagora.com>
@pm-McFly pm-McFly self-assigned this Mar 30, 2026
@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Mar 30, 2026

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit 4bf6b58

Command Status Duration Result
nx affected -t check -- --max-diagnostics none ❌ Failed 9s View ↗
nx affected -t test ✅ Succeeded <1s View ↗
nx affected -t build ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-31 08:40:17 UTC

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

Caution

Review failed

An error occurred during the review process. Please try again later.

📝 Walkthrough

Walkthrough

Removed the user-quota cron job and its test files, updated cron initialization and cron docs to reflect the removal, and applied formatting/TypeScript style changes (quotes, semicolons, import type) across identity-server and tom-server sources.

Changes

Cohort / File(s) Summary
Quota removal
packages/matrix-identity-server/src/cron/check-quota.ts, packages/matrix-identity-server/src/cron/check-quota.test.ts
Deleted the check-quota cron implementation and its Jest test.
Cron init & tests
packages/matrix-identity-server/src/cron/index.ts, packages/matrix-identity-server/src/cron/index.test.ts
Removed private _addCheckUserQuotaJob() and its registration; updated tests (expected cron tasks 4 → 3); normalized imports/formatting and minor control-flow cleanup.
Cron docs
packages/matrix-identity-server/src/AGENTS.md, packages/matrix-identity-server/src/cron/AGENTS.md
Removed references to quota enforcement and the check-quota job; adjusted listed cron jobs.
DB & types formatting
packages/matrix-identity-server/src/db/index.ts, packages/matrix-identity-server/src/types.ts
Non-functional TypeScript/style refactors: double quotes, semicolons, import type, compacted type formatting, and minor null-check tightening.
Tom server formatting
packages/tom-server/src/types.ts, packages/tom-server/src/utils.ts
Formatting-only changes: semicolons, double-quoted string literals, import type, SQL/table string quoting and small helper normalizations.
Repository TODOs
TODO.md
Expanded TODO entries for lint/type fixes and follow-ups (cron tests, db typings, TOM server type cleanup).

Possibly related PRs

Suggested labels

chore, package::identity-server

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly summarizes the main change: removal of user quota-related code across multiple files and modules.
Description check ✅ Passed The description follows the template, provides clear rationale (shift from all-in-one Matrix Protocol to Identity API focus), marks all checklist items complete, and documents the scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/tom-server/src/utils.ts (2)

15-28: ⚠️ Potential issue | 🟡 Minor

Remove duplicate JSDoc.

You've got the same JSDoc comment twice. Pick one, kill the other. The second one says "Combined URL" instead of "URL" but that's not worth the duplication.

🧹 Suggested cleanup
-/**
- * Builds a URL from a base URL and a path
- *
- * `@param` {string} base - Base URL
- * `@param` {string} path - Path
- * `@returns` {string} - URL
- */
 /**
  * Builds a URL from a base URL and a path
  *
  * `@param` {string} base - Base URL
  * `@param` {string} path - Path
  * `@returns` {string} - Combined URL
  */

1-46: ⚠️ Potential issue | 🟡 Minor

Lines 6 and 11 exceed the 120-character hard limit.

Line 6 (invitations schema): 178 characters. Line 11 (usersettings schema): 143 characters. The coding guidelines mandate 120 chars max—break these SQL schema strings into named constants or use a multi-line approach.

Also: your PR description says "removes unmaintained legacy code related to user quotas" with "solely deleting code files." This file shows zero quota deletions—only line breaks and formatting. Either this was pulled in by accident, or the description needs updating to acknowledge the formatting pass. Don't bury unrelated changes in one commit.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a75e8209-4cf1-4df7-9f94-5eaba9b4eadf

📥 Commits

Reviewing files that changed from the base of the PR and between ce3cf13 and 7f9f3a3.

📒 Files selected for processing (10)
  • packages/matrix-identity-server/src/AGENTS.md
  • packages/matrix-identity-server/src/cron/AGENTS.md
  • packages/matrix-identity-server/src/cron/check-quota.test.ts
  • packages/matrix-identity-server/src/cron/check-quota.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
  • packages/tom-server/src/types.ts
  • packages/tom-server/src/utils.ts
💤 Files with no reviewable changes (2)
  • packages/matrix-identity-server/src/cron/check-quota.ts
  • packages/matrix-identity-server/src/cron/check-quota.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test / Test Affected Packages
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{ts,tsx,js,jsx,json,md}

📄 CodeRabbit inference engine (CLAUDE.md)

Use npm run format:check and npm run format:fix for code formatting checks

Files:

  • packages/matrix-identity-server/src/AGENTS.md
  • packages/matrix-identity-server/src/cron/AGENTS.md
  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/tom-server/src/utils.ts
  • packages/tom-server/src/types.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
packages/matrix-identity-server/src/**/*.{ts,js}

📄 CodeRabbit inference engine (CLAUDE.md)

Routes are registered on this.api.get and this.api.post maps and mounted by the parent server

Files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (CODING_STYLE.md)

**/*.{js,ts,jsx,tsx}: Use 2 spaces for indentation, not 4, tabs, or other amounts. Enforce with a formatter.
Opening braces must go on the same line. Never place opening braces on a new line.
Use trailing commas in multi-line structures (arrays, objects, function parameters) to minimize diff noise.
Semicolons are required on all statements. Do not rely on Automatic Semicolon Insertion (ASI).
Enforce a hard line length limit of 120 characters. Break overly complex expressions into named sub-expressions.
Use camelCase for variable and function names.
Use PascalCase for types, interfaces, classes, and enums.
Use SCREAMING_SNAKE_CASE only for module-level primitives that are truly constant and never change. Do not use for local bindings.
Boolean variables must read as a question using prefixes like is, has, can (e.g., isLoading, hasPermission, canRetry). Never use bare noun forms.
Do not abbreviate variable or function names except for: i, j in tight loops; e for event parameters; err for errors; ctx for context; req/res in HTTP handlers.
Each function must do exactly one job. Do not write functions that combine multiple concerns (e.g., avoid fetchAndTransformUser). Extract compound operations into separate functions.
Functions must have a maximum of 5 parameters. For more than 5 parameters, group related data into a typed options object.
Keep functions short, with a reasonable ceiling of 25–40 lines. Functions should fit on one screen without scrolling.
Every function must return a meaningful value. void return types are forbidden. Use ActionResult for functions with no natural data return.
Recursion must be tail-call or converted to an iterative loop. Non-tail-recursive functions are forbidden in production code because JavaScript engines do not reliably optimize tail calls.
Maximum nesting depth is 2 levels (level 0 is function body, level 1 is a block inside it, level 2 is a block inside that). Extract sub-problems into named functi...

Files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/tom-server/src/utils.ts
  • packages/tom-server/src/types.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CODING_STYLE.md)

**/*.{ts,tsx}: Return types must be explicitly annotated on all non-trivial functions in TypeScript. Inference alone is not a contract.
The any type is forbidden without exception in TypeScript. Use a proper type, discriminated union, unknown with a guard, or a generic instead.
Double casts via as unknown as T are forbidden. If the type model is inconsistent, fix the model instead.
Use unknown over any for data from external sources (HTTP responses, JSON.parse, event payloads, database rows). Write a type guard to validate the data.
Prefer type for unions and intersections; prefer interface for object shapes. Keep intent readable through consistent use.
Avoid TypeScript enum. Use string union types for fully internal values. For values from external sources, provide a validation helper that narrows conversion from raw strings.
In TypeScript, caught values have type unknown, not Error. Use instanceof Error checks before accessing Error-specific properties.
Do not use @ts-ignore or @ts-expect-error without an explanatory comment stating the reason and removal condition.

Do not introduce new any types in TypeScript — existing any warnings are tech debt, but new ones are blockers

Files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/tom-server/src/utils.ts
  • packages/tom-server/src/types.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
packages/tom-server/**/*.{ts,tsx}

📄 CodeRabbit inference engine (packages/tom-server/AGENTS.md)

packages/tom-server/**/*.{ts,tsx}: TwakeServer constructor requires conf parameter with mandatory server_name and base_url properties
Mount TwakeServer endpoints by accessing this.endpoints (Express Router) and using app.use('/', server.endpoints)
Await the this.ready Promise before handling requests to ensure DB, key generation, and all services are initialized

Files:

  • packages/tom-server/src/utils.ts
  • packages/tom-server/src/types.ts
packages/tom-server/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (packages/tom-server/AGENTS.md)

Pass singleton services (AddressbookService, UserInfoService, TokenService, SmsService) created in _initServer() to API modules via dependency injection

Files:

  • packages/tom-server/src/utils.ts
  • packages/tom-server/src/types.ts
packages/tom-server/src/**/*.{ts,js}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/tom-server/src/**/*.{ts,js}: TwakeServer extends MatrixIdentityServer and adds a second DB connection to the Matrix (Synapse) database via MatrixDB
Feature API modules follow a consistent pattern: routes/controllers/services/ with middlewares/ and types.ts

Files:

  • packages/tom-server/src/utils.ts
  • packages/tom-server/src/types.ts
packages/tom-server/src/types.ts

📄 CodeRabbit inference engine (CLAUDE.md)

See packages/tom-server/src/types.ts (Config type) for all configuration options

Files:

  • packages/tom-server/src/types.ts
packages/matrix-identity-server/src/db/**/*.{ts,js}

📄 CodeRabbit inference engine (CLAUDE.md)

MatrixIdentityServer initializes two databases: IdentityServerDb (identity-server tables) and UserDB (user directory)

Files:

  • packages/matrix-identity-server/src/db/index.ts
🧠 Learnings (67)
📓 Common learnings
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/**/*.ts : Use `node-cron` schedule syntax for new jobs in the cron directory
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/**/*.ts : Cron intervals are configured via config keys (e.g., `pepper_cron`, `userdb_cron`)
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/cron/*.ts : Configure cron job intervals via config keys; cron jobs run on server startup
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/matrix-identity-server/src/db/**/*.{ts,js} : `MatrixIdentityServer` initializes two databases: `IdentityServerDb` (identity-server tables) and `UserDB` (user directory)
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Keep Synapse DB schema queries minimal and schema-version-aware to accommodate changes between Synapse versions
📚 Learning: 2026-03-17T11:21:55.851Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/**/*.ts : Cron intervals are configured via config keys (e.g., `pepper_cron`, `userdb_cron`)

Applied to files:

  • packages/matrix-identity-server/src/AGENTS.md
  • packages/matrix-identity-server/src/cron/AGENTS.md
  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:21:55.851Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/**/*.ts : Use `node-cron` schedule syntax for new jobs in the cron directory

Applied to files:

  • packages/matrix-identity-server/src/AGENTS.md
  • packages/matrix-identity-server/src/cron/AGENTS.md
  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:21:55.851Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/changePepper.ts : `changePepper.ts` is a critical job that invalidates all existing hashes and rebuilds them — run carefully

Applied to files:

  • packages/matrix-identity-server/src/AGENTS.md
  • packages/matrix-identity-server/src/cron/AGENTS.md
  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:21:40.136Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/cron/*.ts : Configure cron job intervals via config keys; cron jobs run on server startup

Applied to files:

  • packages/matrix-identity-server/src/AGENTS.md
  • packages/matrix-identity-server/src/cron/AGENTS.md
  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:22:24.131Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Use matrixDb queries in cron/changePepper.ts to filter active Matrix users when updating hashes

Applied to files:

  • packages/matrix-identity-server/src/AGENTS.md
  • packages/matrix-identity-server/src/cron/AGENTS.md
  • packages/matrix-identity-server/src/cron/index.ts
📚 Learning: 2026-03-17T11:22:24.131Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Keep Synapse DB schema queries minimal and schema-version-aware to accommodate changes between Synapse versions

Applied to files:

  • packages/matrix-identity-server/src/AGENTS.md
  • packages/matrix-identity-server/src/cron/AGENTS.md
  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/tom-server/src/utils.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-23T09:08:39.061Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/matrix-identity-server/src/db/**/*.{ts,js} : `MatrixIdentityServer` initializes two databases: `IdentityServerDb` (identity-server tables) and `UserDB` (user directory)

Applied to files:

  • packages/matrix-identity-server/src/AGENTS.md
  • packages/matrix-identity-server/src/cron/AGENTS.md
  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/tom-server/src/types.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:20:10.724Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/common-settings-bridge/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:10.724Z
Learning: Applies to packages/common-settings-bridge/src/src/common-settings-bridge/matrix-profile-updater.ts : Update Matrix user profiles via the homeserver API using the `matrix-profile-updater` module

Applied to files:

  • packages/matrix-identity-server/src/AGENTS.md
  • packages/matrix-identity-server/src/cron/index.ts
📚 Learning: 2026-03-17T11:21:27.917Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:27.917Z
Learning: Applies to packages/matrix-identity-server/src/{account,3pid,lookup,terms,validate,keyManagement}/**/*.ts : All spec endpoints should be mounted at /_matrix/identity/v2/

Applied to files:

  • packages/matrix-identity-server/src/AGENTS.md
  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:22:57.617Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-resolve/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:57.617Z
Learning: Applies to packages/matrix-resolve/src/**/*.ts : Implement `matrixResolve()` as a simple stateless API without caching for resolving Matrix homeserver addresses

Applied to files:

  • packages/matrix-identity-server/src/AGENTS.md
  • packages/matrix-identity-server/src/cron/index.ts
📚 Learning: 2026-03-17T11:23:13.313Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:13.313Z
Learning: Applies to packages/tom-server/src/@(addressbook-api|admin-settings-api|deactivate-account-api|invitation-api|matrix-api|metrics-api|qrcode-api|sms-api|user-info-api|vault-api|wellKnown)/**/*.{ts,tsx} : All API modules must follow the pattern: `routes/index.ts` → router → `controllers/` + `middlewares/` + `services/`

Applied to files:

  • packages/matrix-identity-server/src/AGENTS.md
📚 Learning: 2026-03-17T11:21:40.136Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/index.ts : Register new Matrix Identity Server endpoints in `index.ts` and mount them at `/_matrix/identity/v2/` prefix

Applied to files:

  • packages/matrix-identity-server/src/AGENTS.md
  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-23T09:08:39.061Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/matrix-identity-server/src/**/*.{ts,js} : Routes are registered on `this.api.get` and `this.api.post` maps and mounted by the parent server

Applied to files:

  • packages/matrix-identity-server/src/AGENTS.md
📚 Learning: 2026-03-23T09:08:39.061Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/tom-server/src/**/*.{ts,js} : Feature API modules follow a consistent pattern: `routes/` → `controllers/` → `services/` with `middlewares/` and `types.ts`

Applied to files:

  • packages/matrix-identity-server/src/AGENTS.md
📚 Learning: 2026-03-17T11:21:40.136Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Organize Matrix Identity Server feature modules to mirror the Matrix Identity Server v2 specification, with each subdirectory handling one area of the spec

Applied to files:

  • packages/matrix-identity-server/src/AGENTS.md
📚 Learning: 2026-03-17T11:23:51.582Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:51.582Z
Learning: Applies to packages/tom-server/src/identity-server/identity-server/{index.test,with-cache.test}.ts : Write integration tests for TwakeIdentityServer in index.test.ts and cache-enabled lookup behavior in with-cache.test.ts

Applied to files:

  • packages/matrix-identity-server/src/AGENTS.md
  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:23:21.167Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:21.167Z
Learning: Applies to packages/tom-server/src/**/*/routes/index.ts : Follow the module structure pattern: `module/routes/index.ts` defines the Express Router and imports from `controllers/` and `middlewares/`

Applied to files:

  • packages/matrix-identity-server/src/AGENTS.md
📚 Learning: 2026-03-17T11:21:27.917Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:27.917Z
Learning: Applies to packages/matrix-identity-server/src/index.ts : this.endpoints is an Express Router — mount it in the parent application

Applied to files:

  • packages/matrix-identity-server/src/AGENTS.md
📚 Learning: 2026-03-17T11:22:18.337Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/lookup/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:18.337Z
Learning: Pepper should be stored in the database and rotated by the cron/changePepper.ts job

Applied to files:

  • packages/matrix-identity-server/src/cron/AGENTS.md
  • packages/matrix-identity-server/src/cron/index.ts
📚 Learning: 2026-03-17T11:22:18.337Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/lookup/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:18.337Z
Learning: Applies to packages/matrix-identity-server/src/lookup/lookup/updateHash.ts : Use generic-pool for concurrency control with a worker pool limit of 5 workers in updateHash.ts during pepper rotation

Applied to files:

  • packages/matrix-identity-server/src/cron/AGENTS.md
  • packages/matrix-identity-server/src/cron/index.ts
📚 Learning: 2026-03-23T09:08:39.061Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/tom-server/src/**/*.{ts,js} : `TwakeServer` extends `MatrixIdentityServer` and adds a second DB connection to the Matrix (Synapse) database via `MatrixDB`

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/tom-server/src/utils.ts
  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:23:51.582Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:51.582Z
Learning: Applies to packages/tom-server/src/identity-server/identity-server/index.ts : TwakeIdentityServer must add twakeDbCollections to extend the identity server database schema

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/tom-server/src/types.ts
  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:35.300Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/crypto/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:35.300Z
Learning: Applies to packages/crypto/**/*.{ts,tsx} : In the `twake/crypto` package, the `Hash` class requires async initialization via `await hash.ready` before calling `.sha256()` or `.sha512()`

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
📚 Learning: 2026-03-17T11:21:16.677Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/logger/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:16.677Z
Learning: Applies to packages/logger/**/*.{ts,tsx} : Use `getLogger(conf?, confDesc?)` as the main factory function to obtain a Winston `Logger` instance typed as `TwakeLogger`

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
📚 Learning: 2026-03-17T11:21:16.677Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/logger/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:16.677Z
Learning: Applies to packages/logger/**/*.{ts,tsx} : Type dependency-injected logger instances as `TwakeLogger` type alias for Winston's `Logger`

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
📚 Learning: 2026-03-17T11:21:16.677Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/logger/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:16.677Z
Learning: Applies to packages/logger/src/index.ts : The main export file `src/index.ts` must export: `getLogger()`, `ETransportType`, `Config` type, and `TwakeLogger` type

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:20:10.724Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/common-settings-bridge/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:10.724Z
Learning: Applies to packages/common-settings-bridge/src/src/common-settings-bridge/**/*.test.ts : Mock the `matrix-appservice-bridge` library in Jest tests using the mock in `__mocks__/matrix-appservice-bridge.ts`

Applied to files:

  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:23:13.313Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:13.313Z
Learning: Applies to packages/tom-server/**/*.{test,spec}.{ts,tsx} : Tests must use SQLite in-memory database and mock external services (SMTP, Matrix homeserver) rather than using real services

Applied to files:

  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/tom-server/src/utils.ts
📚 Learning: 2026-03-17T11:22:24.131Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Support both PostgreSQL and SQLite Synapse configurations with driver-specific queries

Applied to files:

  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/tom-server/src/utils.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:20:46.846Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:46.846Z
Learning: Applies to packages/db/**/*.test.{ts,tsx} : Use SQLite in-memory database for test isolation in twake/db tests

Applied to files:

  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:21:16.677Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/logger/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:16.677Z
Learning: Run tests using `npx nx run twake/logger:test`

Applied to files:

  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-23T09:08:39.061Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to **/jest.config.{ts,js} : Tests use Jest + ts-jest and `testcontainers` for spinning up real PostgreSQL/LDAP in CI

Applied to files:

  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:22:06.022Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/sql/{pg,sqlite}.ts : When adding a new table, define schema in `db/index.ts`, and add SQL implementations in both `db/sql/pg.ts` (PostgreSQL) and `db/sql/sqlite.ts` (SQLite)

Applied to files:

  • packages/tom-server/src/utils.ts
  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:22:06.022Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/**/*.ts : All SQL queries must use parameterized statements — never string-interpolate user input into SQL

Applied to files:

  • packages/tom-server/src/utils.ts
  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:56.983Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/sql.ts : In `db/src/sql/sql.ts`, implement base SQL utilities and shared query logic

Applied to files:

  • packages/tom-server/src/utils.ts
  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:21:40.136Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/db/index.ts : Add new database table names to the `Collections` enum in `db/index.ts`

Applied to files:

  • packages/tom-server/src/utils.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:22:06.022Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/index.ts : Add new identity server tables to the `Collections` enum in `db/index.ts`

Applied to files:

  • packages/tom-server/src/utils.ts
  • packages/tom-server/src/types.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:24:38.144Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/user-info-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:38.144Z
Learning: Applies to packages/tom-server/src/user-info-api/user-info-api/**/*.ts : Store visibility settings in the identity server DB (not MatrixDB)

Applied to files:

  • packages/tom-server/src/utils.ts
  • packages/tom-server/src/types.ts
  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:22:24.131Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Reference configuration keys: matrix_database_engine (pg/sqlite), matrix_database_host, matrix_database_name for database connections

Applied to files:

  • packages/tom-server/src/utils.ts
  • packages/tom-server/src/types.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:23:21.167Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:21.167Z
Learning: Applies to packages/tom-server/src/src/types.ts : Global type definitions and shared interfaces must be defined in `types.ts`

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:23:51.582Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:51.582Z
Learning: Applies to packages/tom-server/src/identity-server/identity-server/index.ts : TwakeIdentityServer should extend MatrixIdentityServer with Twake-specific user lookup and search capabilities

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:23:35.727Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/admin-settings-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:35.727Z
Learning: Applies to packages/tom-server/src/admin-settings-api/admin-settings-api/**/*.ts : Admin-settings-api module structure should follow the pattern: index.ts for module export, routes/, controllers/, middlewares/, services/, tests/, and types.ts for type definitions

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:23:13.313Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:13.313Z
Learning: Applies to packages/tom-server/**/*.{ts,tsx} : TwakeServer constructor requires `conf` parameter with mandatory `server_name` and `base_url` properties

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:23:13.313Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:13.313Z
Learning: Applies to packages/tom-server/src/**/*.{ts,tsx} : Pass singleton services (AddressbookService, UserInfoService, TokenService, SmsService) created in `_initServer()` to API modules via dependency injection

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:24:32.491Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/sms-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:32.491Z
Learning: Applies to packages/tom-server/src/sms-api/sms-api/index.ts : Export all public API and types from index.ts in the sms-api module

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:21:27.917Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:27.917Z
Learning: Applies to packages/matrix-identity-server/src/index.ts : MatrixIdentityServer constructor takes (conf, confDesc?, db?) — conf must include server_name

Applied to files:

  • packages/tom-server/src/types.ts
  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:24:48.682Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/wellKnown/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:48.682Z
Learning: Applies to packages/tom-server/src/wellKnown/wellKnown/index.ts : Include response fields for Matrix client auto-discovery: `m.homeserver.base_url`, `m.identity_server.base_url`, `m.integrations`, `org.matrix.msc3575.proxy`, and Jitsi, OIDC, and Twake-specific keys

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:23:35.727Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/admin-settings-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:35.727Z
Learning: Applies to packages/tom-server/src/admin-settings-api/admin-settings-api/middlewares/**/*.{ts,tsx,js} : Admin token validation middleware must be implemented separately from Matrix authentication to allow machine-to-machine admin operations

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:21:40.136Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/userdb/*.ts : Select userdb backend via `user_db` config key: `sqlite`, `pg`, `ldap`, or empty string

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:21:27.917Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:27.917Z
Learning: Applies to packages/matrix-identity-server/src/index.ts : The db property exposes the identity server's database for subclass use

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:21:27.917Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:27.917Z
Learning: Applies to packages/matrix-identity-server/src/index.ts : this.ready is a Promise that resolves when async initialization (key gen, DB setup) completes

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:56.983Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/index.ts : In `db/src/index.ts`, export the main `Database` class, `Pg`, `SQLite`, and `createTables` function

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:56.983Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/database.ts : In `db/src/database.ts`, implement the `Database` base class for connection management and query interface

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:56.983Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/_createTables.ts : In `db/src/sql/_createTables.ts`, implement `createTables()` function to create tables from schema definitions if they don't exist

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:46.846Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:46.846Z
Learning: Applies to packages/db/src/index.ts : Export `Database` class, adapter implementations (`Pg`, `SQLite`), `createTables` function, and column/condition types from `src/index.ts` in twake/db

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:22:24.131Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Implement query methods getAll(), get(), and match() in the MatrixDB class for querying Synapse tables

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:56.983Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/types.ts : In `db/src/types.ts`, define column definitions, condition operators, and table schema types

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:21:45.978Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/account/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:45.978Z
Learning: Applies to packages/matrix-identity-server/src/account/account/{register,logout}.ts : Access tokens are stored in the `accessTokens` DB collection

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:23:13.313Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:13.313Z
Learning: Applies to packages/tom-server/**/*.{ts,tsx} : Await the `this.ready` Promise before handling requests to ensure DB, key generation, and all services are initialized

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:21:45.978Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/account/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:45.978Z
Learning: Applies to packages/matrix-identity-server/src/account/account/logout.ts : POST `/_matrix/identity/v2/account/logout` endpoint deletes the current access token from DB

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:22:12.102Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/keyManagement/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:12.102Z
Learning: Applies to packages/matrix-identity-server/src/keyManagement/keyManagement/**/*.ts : Use Ed25519 for public key management in the Matrix Identity Server

Applied to files:

  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:22:12.102Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/keyManagement/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:12.102Z
Learning: Applies to packages/matrix-identity-server/src/keyManagement/keyManagement/**/*.ts : Use `keyId` format of `ed25519:<base64url-encoded-public-key>` for identifying keys

Applied to files:

  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:20:10.724Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/common-settings-bridge/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:10.724Z
Learning: Applies to packages/common-settings-bridge/src/src/common-settings-bridge/types.ts : Use TypeScript type definitions in `types.ts` for bridge configuration and events

Applied to files:

  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:22:45.233Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/utils/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:45.233Z
Learning: Applies to packages/matrix-identity-server/src/utils/**/utils/mailer.ts : SMTP configuration in `mailer.ts` should use keys: `smtp_server`, `smtp_port`, `smtp_user`, `smtp_password`, `smtp_tls`

Applied to files:

  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:22:38.835Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/userdb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:38.835Z
Learning: Applies to packages/matrix-identity-server/src/userdb/userdb/**/*.ts : All backends in the userdb module must implement the same interface with methods `get()`, `getAll()`, and `match()` for querying user information

Applied to files:

  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:24:32.491Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/sms-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:32.491Z
Learning: Applies to packages/tom-server/src/sms-api/sms-api/types.ts : Define request and response type definitions for the SMS API endpoint in types.ts, including phone number format and SMS response structure

Applied to files:

  • packages/matrix-identity-server/src/types.ts
🪛 Biome (2.4.9)
packages/matrix-identity-server/src/cron/index.ts

[error] 45-45: Using != may be unsafe if you are relying on type coercion.

(lint/suspicious/noDoubleEquals)


[error] 53-53: Use new Error() instead of Error() when throwing an error.

(lint/style/useThrowNewError)


[error] 132-132: Use new Error() instead of Error() when throwing an error.

(lint/style/useThrowNewError)


[error] 130-130: This catch binding is unused.

(lint/complexity/noUselessCatchBinding)


[error] 130-130: This variable error is unused.

(lint/correctness/noUnusedVariables)

packages/matrix-identity-server/src/cron/index.test.ts

[error] 68-68: The catch clause that only rethrows the original error is useless.

(lint/complexity/noUselessCatch)


[error] 50-50: This catch binding is unused.

(lint/complexity/noUselessCatchBinding)


[error] 50-50: This variable error is unused.

(lint/correctness/noUnusedVariables)

packages/tom-server/src/types.ts

[error] 6-6: This import is unused.

(lint/correctness/noUnusedImports)

packages/matrix-identity-server/src/db/index.ts

[error] 109-116: Function has 6 parameters, but only 5 are allowed.

(lint/complexity/useMaxParams)


[error] 117-125: Function has 7 parameters, but only 5 are allowed.

(lint/complexity/useMaxParams)


[error] 144-144: Unexpected any. Specify a different type.

(lint/suspicious/noExplicitAny)


[error] 182-182: This variable implicitly has the any type.

(lint/suspicious/noImplicitAnyLet)


[error] 199-199: Using != may be unsafe if you are relying on type coercion.

(lint/suspicious/noDoubleEquals)


[error] 200-200: Using != may be unsafe if you are relying on type coercion.

(lint/suspicious/noDoubleEquals)


[error] 202-202: Using != may be unsafe if you are relying on type coercion.

(lint/suspicious/noDoubleEquals)


[error] 219-219: Don't use console.

(lint/suspicious/noConsole)


[error] 415-415: Using == may be unsafe if you are relying on type coercion.

(lint/suspicious/noDoubleEquals)


[error] 424-424: Using != may be unsafe if you are relying on type coercion.

(lint/suspicious/noDoubleEquals)


[error] 451-451: Using == may be unsafe if you are relying on type coercion.

(lint/suspicious/noDoubleEquals)


[error] 481-481: Using == may be unsafe if you are relying on type coercion.

(lint/suspicious/noDoubleEquals)


[error] 500-500: Using == may be unsafe if you are relying on type coercion.

(lint/suspicious/noDoubleEquals)


[error] 525-525: Using == may be unsafe if you are relying on type coercion.

(lint/suspicious/noDoubleEquals)


[error] 536-536: Template literals are preferred over string concatenation.

(lint/style/useTemplate)


[error] 549-549: Using == may be unsafe if you are relying on type coercion.

(lint/suspicious/noDoubleEquals)


[error] 571-571: Using == may be unsafe if you are relying on type coercion.

(lint/suspicious/noDoubleEquals)


[error] 592-592: Using == may be unsafe if you are relying on type coercion.

(lint/suspicious/noDoubleEquals)


[error] 622-622: Using == may be unsafe if you are relying on type coercion.

(lint/suspicious/noDoubleEquals)


[error] 674-674: Using == may be unsafe if you are relying on type coercion.

(lint/suspicious/noDoubleEquals)


[error] 489-489: Don't use console.

(lint/suspicious/noConsole)


[error] 647-647: Don't use console.

(lint/suspicious/noConsole)


[error] 663-663: Don't use console.

(lint/suspicious/noConsole)

packages/matrix-identity-server/src/types.ts

[error] 31-31: Unexpected any. Specify a different type.

(lint/suspicious/noExplicitAny)

🪛 GitHub Check: CodeQL
packages/matrix-identity-server/src/cron/index.ts

[failure] 46-46: Clear-text logging of sensitive information
This logs sensitive data returned by process environment as clear text.
This logs sensitive data returned by an access to DATABASE_PASSWORD as clear text.
This logs sensitive data returned by an access to database_password as clear text.
This logs sensitive data returned by an access to LDAP_PASSWORD as clear text.
This logs sensitive data returned by an access to ldap_password as clear text.
This logs sensitive data returned by an access to MATRIX_DATABASE_PASSWORD as clear text.
This logs sensitive data returned by an access to matrix_database_password as clear text.
This logs sensitive data returned by an access to USERDB_PASSWORD as clear text.
This logs sensitive data returned by an access to userdb_password as clear text.
This logs sensitive data returned by process environment as clear text.
This logs sensitive data returned by an access to sms_api_key as clear text.
This logs sensitive data returned by an access to SMS_API_KEY as clear text.
This logs sensitive data returned by an access to MATRIX_ADMIN_PASSWORD as clear text.
This logs sensitive data returned by an access to DATABASE_PASSWORD as clear text.
This logs sensitive data returned by an access to database_password as clear text.
This logs sensitive data returned by an access to LDAP_PASSWORD as clear text.
This logs sensitive data returned by an access to ldap_password as clear text.
This logs sensitive data returned by an access to MATRIX_DATABASE_PASSWORD as clear text.
This logs sensitive data returned by an access to matrix_database_password as clear text.
This logs sensitive data returned by an access to SMTP_PASSWORD as clear text.
This logs sensitive data returned by an access to smtp_password as clear text.
This logs sensitive data returned by an access to USERDB_PASSWORD as clear text.
This logs sensitive data returned by an access to userdb_password as clear text.
This logs sensitive data returned by an access to sms_api_key as clear text.
This logs sensitive data returned by an access to SMS_API_KEY as clear text.
This logs sensitive data returned by an access to MATRIX_ADMIN_PASSWORD as clear text.
This logs sensitive data returned by an access to DATABASE_PASSWORD as clear text.
This logs sensitive data returned by an access to database_password as clear text.
This logs sensitive data returned by process environment as clear text.
This logs sensitive data returned by an access to LDAP_PASSWORD as clear text.
This logs sensitive data returned by an access to ldap_password as clear text.
This logs sensitive data returned by an access to MATRIX_DATABASE_PASSWORD as clear text.
This logs sensitive data returned by an access to matrix_database_password as clear text.
This logs sensitive data returned by an access to sms_api_key as clear text.
This logs sensitive data returned by an access to SMS_API_KEY as clear text.
This logs sensitive data returned by an access to MATRIX_ADMIN_PASSWORD as clear text.
This logs sensitive data returned by an access to SMTP_PASSWORD as clear text.
This logs sensitive data returned by an access to smtp_password as clear text.


[failure] 105-105: Clear-text logging of sensitive information
This logs sensitive data returned by process environment as clear text.
This logs sensitive data returned by an access to DATABASE_PASSWORD as clear text.
This logs sensitive data returned by an access to database_password as clear text.
This logs sensitive data returned by an access to LDAP_PASSWORD as clear text.
This logs sensitive data returned by an access to ldap_password as clear text.
This logs sensitive data returned by an access to MATRIX_DATABASE_PASSWORD as clear text.
This logs sensitive data returned by an access to matrix_database_password as clear text.
This logs sensitive data returned by an access to USERDB_PASSWORD as clear text.
This logs sensitive data returned by an access to userdb_password as clear text.
This logs sensitive data returned by process environment as clear text.
This logs sensitive data returned by an access to sms_api_key as clear text.
This logs sensitive data returned by an access to SMS_API_KEY as clear text.
This logs sensitive data returned by an access to MATRIX_ADMIN_PASSWORD as clear text.
This logs sensitive data returned by an access to DATABASE_PASSWORD as clear text.
This logs sensitive data returned by an access to database_password as clear text.
This logs sensitive data returned by an access to LDAP_PASSWORD as clear text.
This logs sensitive data returned by an access to ldap_password as clear text.
This logs sensitive data returned by an access to MATRIX_DATABASE_PASSWORD as clear text.
This logs sensitive data returned by an access to matrix_database_password as clear text.
This logs sensitive data returned by an access to SMTP_PASSWORD as clear text.
This logs sensitive data returned by an access to smtp_password as clear text.
This logs sensitive data returned by an access to USERDB_PASSWORD as clear text.
This logs sensitive data returned by an access to userdb_password as clear text.
This logs sensitive data returned by an access to sms_api_key as clear text.
This logs sensitive data returned by an access to SMS_API_KEY as clear text.
This logs sensitive data returned by an access to MATRIX_ADMIN_PASSWORD as clear text.
This logs sensitive data returned by an access to DATABASE_PASSWORD as clear text.
This logs sensitive data returned by an access to database_password as clear text.
This logs sensitive data returned by process environment as clear text.
This logs sensitive data returned by an access to LDAP_PASSWORD as clear text.
This logs sensitive data returned by an access to ldap_password as clear text.
This logs sensitive data returned by an access to MATRIX_DATABASE_PASSWORD as clear text.
This logs sensitive data returned by an access to matrix_database_password as clear text.
This logs sensitive data returned by an access to sms_api_key as clear text.
This logs sensitive data returned by an access to SMS_API_KEY as clear text.
This logs sensitive data returned by an access to MATRIX_ADMIN_PASSWORD as clear text.
This logs sensitive data returned by an access to SMTP_PASSWORD as clear text.
This logs sensitive data returned by an access to smtp_password as clear text.

🪛 GitHub Check: devskim
packages/matrix-identity-server/src/db/index.ts

[notice] 620-620: Generic: Hard-coded Elliptic Curve
Generic: Hard-coded Elliptic Curve


[notice] 702-702: If untrusted data (data from HTTP requests, user submitted files, etc.) is included in an setTimeout statement it can allow an attacker to inject their own code.
Review setTimeout for untrusted data


[notice] 704-704: If untrusted data (data from HTTP requests, user submitted files, etc.) is included in an setTimeout statement it can allow an attacker to inject their own code.
Review setTimeout for untrusted data

🔇 Additional comments (8)
packages/matrix-identity-server/src/cron/index.ts (2)

46-46: CodeQL false positive — this is not sensitive data.

The warning about "clear-text logging of sensitive information" is bogus here. You're logging conf.federated_identity_services.join(", ") which is an array of server hostnames, not passwords. CodeQL is being overly paranoid because conf object also contains password fields elsewhere.


40-55: Quota job removal is clean and complete.

The _addCheckUserQuotaJob reference is properly excised. The remaining task registration logic is correct.

packages/matrix-identity-server/src/cron/AGENTS.md (1)

7-19: LGTM — docs accurately reflect the quota job removal.

The Purpose section and Key Files table are now consistent with the actual cron directory contents after removing check-quota.ts and its test.

packages/matrix-identity-server/src/AGENTS.md (1)

30-30: LGTM — cron subdirectory description updated correctly.

packages/tom-server/src/types.ts (1)

1-9: Formatting consolidation looks good.

Import cleanup and style normalization aligns with the repo-wide formatting effort.

packages/matrix-identity-server/src/types.ts (1)

1-126: Pure formatting normalization — no functional changes.

The any in ldapts_opts (line 31) is pre-existing tech debt, not introduced by this PR. Don't let perfect be the enemy of good — the quota removal is the actual mission here.

packages/matrix-identity-server/src/db/index.ts (1)

1-712: Formatting-only changes — no functional modifications.

The static analysis is screaming about ==, console.log, and any — all pre-existing sins. This PR isn't here to atone for legacy crimes, just to excise the dead quota code. The formatting normalization is fine.

packages/matrix-identity-server/src/cron/index.test.ts (1)

84-84: Task count assertion correctly updated for quota removal.

Three tasks remaining: updateHashes, updateUsers, and federatedIdentityUpdates. Math checks out.

profileSettings:
'matrix_id varchar(64) PRIMARY KEY, visibility VARCHAR(20) NOT NULL, visible_fields TEXT[] NOT NULL'
}
profileSettings: "matrix_id varchar(64) PRIMARY KEY, visibility VARCHAR(20) NOT NULL, visible_fields TEXT[] NOT NULL",
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Mar 30, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

PostgreSQL-specific array syntax breaks SQLite compatibility.

The TEXT[] type is PostgreSQL-only. SQLite has no native array type and will choke on this schema. Your table definitions here appear to be shared across database engines, which means you've just broken SQLite support.

Either:

  1. Use JSON serialization (TEXT column storing JSON array) for cross-database compatibility
  2. Split this into driver-specific schema definitions in db/sql/pg.ts and db/sql/sqlite.ts

Based on learnings: "Support both PostgreSQL and SQLite Synapse configurations with driver-specific queries" and "When adding a new table, define schema in db/index.ts, and add SQL implementations in both db/sql/pg.ts (PostgreSQL) and db/sql/sqlite.ts (SQLite)"

🔧 Option 1: Use JSON for cross-database compatibility
-  profileSettings: "matrix_id varchar(64) PRIMARY KEY, visibility VARCHAR(20) NOT NULL, visible_fields TEXT[] NOT NULL",
+  profileSettings: "matrix_id varchar(64) PRIMARY KEY, visibility VARCHAR(20) NOT NULL, visible_fields TEXT NOT NULL",

Store the array as JSON text, then parse/stringify in application code.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@coderabbitai you got a valid point but this is outside of this PR scope

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@pm-McFly, understood — this PR's scope is quota removal and I won't block it on a pre-existing issue. Would you like me to open a follow-up GitHub issue to track the TEXT[] SQLite incompatibility in profileSettings?


🧠 Learnings used
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/db/index.ts : Add new database table names to the `Collections` enum in `db/index.ts`

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/index.ts : Add new identity server tables to the `Collections` enum in `db/index.ts`

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/sql/{pg,sqlite}.ts : When adding a new table, define schema in `db/index.ts`, and add SQL implementations in both `db/sql/pg.ts` (PostgreSQL) and `db/sql/sqlite.ts` (SQLite)

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Keep Synapse DB schema queries minimal and schema-version-aware to accommodate changes between Synapse versions

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Support both PostgreSQL and SQLite Synapse configurations with driver-specific queries

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/matrix-identity-server/src/db/**/*.{ts,js} : `MatrixIdentityServer` initializes two databases: `IdentityServerDb` (identity-server tables) and `UserDB` (user directory)

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/vault-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:43.558Z
Learning: Applies to packages/tom-server/src/vault-api/vault-api/**/*.ts : Recovery words are stored encrypted in the database — use `utils.ts` for encryption/decryption operations

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Reference configuration keys: matrix_database_engine (pg/sqlite), matrix_database_host, matrix_database_name for database connections

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/**/*.ts : Never write to Synapse tables from the matrixDb module — implement read-only access to the Matrix homeserver (Synapse) database

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Implement query methods getAll(), get(), and match() in the MatrixDB class for querying Synapse tables

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/sqlite.ts : In `db/src/sql/sqlite.ts`, implement SQLite adapter using `sqlite3` or `better-sqlite3`

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/userdb/*.ts : Select userdb backend via `user_db` config key: `sqlite`, `pg`, `ldap`, or empty string

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/**/*.ts : All SQL queries must use parameterized statements — never string-interpolate user input into SQL

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/pg.ts : In `db/src/sql/pg.ts`, implement PostgreSQL adapter using `pg` driver with connection pooling and parameterized queries

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:13.313Z
Learning: Applies to packages/tom-server/**/*.{test,spec}.{ts,tsx} : Tests must use SQLite in-memory database and mock external services (SMTP, Matrix homeserver) rather than using real services

Learnt from: pm-McFly
Repo: linagora/ToM-server PR: 355
File: packages/matrix-identity-server/src/db/index.ts:413-413
Timestamp: 2026-03-31T07:26:27.898Z
Learning: When reviewing TypeScript code in this repo, follow Biome’s `noDoubleEquals` rule: do not use loose equality (`== null` / `!= null`) as a shorthand. For nullish checks, use explicit strict comparisons instead (e.g., `value === null || value === undefined` or `value !== null && value !== undefined`).

Signed-off-by: Pierre 'McFly' Marty <pmarty@linagora.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5896bc15-3fcb-40aa-a600-d9b0a40f2866

📥 Commits

Reviewing files that changed from the base of the PR and between 7f9f3a3 and 5d3a504.

📒 Files selected for processing (1)
  • packages/tom-server/src/types.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test / Test Affected Packages
🧰 Additional context used
📓 Path-based instructions (7)
packages/tom-server/**/*.{ts,tsx}

📄 CodeRabbit inference engine (packages/tom-server/AGENTS.md)

packages/tom-server/**/*.{ts,tsx}: TwakeServer constructor requires conf parameter with mandatory server_name and base_url properties
Mount TwakeServer endpoints by accessing this.endpoints (Express Router) and using app.use('/', server.endpoints)
Await the this.ready Promise before handling requests to ensure DB, key generation, and all services are initialized

Files:

  • packages/tom-server/src/types.ts
packages/tom-server/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (packages/tom-server/AGENTS.md)

Pass singleton services (AddressbookService, UserInfoService, TokenService, SmsService) created in _initServer() to API modules via dependency injection

Files:

  • packages/tom-server/src/types.ts
**/*.{ts,tsx,js,jsx,json,md}

📄 CodeRabbit inference engine (CLAUDE.md)

Use npm run format:check and npm run format:fix for code formatting checks

Files:

  • packages/tom-server/src/types.ts
packages/tom-server/src/**/*.{ts,js}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/tom-server/src/**/*.{ts,js}: TwakeServer extends MatrixIdentityServer and adds a second DB connection to the Matrix (Synapse) database via MatrixDB
Feature API modules follow a consistent pattern: routes/controllers/services/ with middlewares/ and types.ts

Files:

  • packages/tom-server/src/types.ts
packages/tom-server/src/types.ts

📄 CodeRabbit inference engine (CLAUDE.md)

See packages/tom-server/src/types.ts (Config type) for all configuration options

Files:

  • packages/tom-server/src/types.ts
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (CODING_STYLE.md)

**/*.{js,ts,jsx,tsx}: Use 2 spaces for indentation, not 4, tabs, or other amounts. Enforce with a formatter.
Opening braces must go on the same line. Never place opening braces on a new line.
Use trailing commas in multi-line structures (arrays, objects, function parameters) to minimize diff noise.
Semicolons are required on all statements. Do not rely on Automatic Semicolon Insertion (ASI).
Enforce a hard line length limit of 120 characters. Break overly complex expressions into named sub-expressions.
Use camelCase for variable and function names.
Use PascalCase for types, interfaces, classes, and enums.
Use SCREAMING_SNAKE_CASE only for module-level primitives that are truly constant and never change. Do not use for local bindings.
Boolean variables must read as a question using prefixes like is, has, can (e.g., isLoading, hasPermission, canRetry). Never use bare noun forms.
Do not abbreviate variable or function names except for: i, j in tight loops; e for event parameters; err for errors; ctx for context; req/res in HTTP handlers.
Each function must do exactly one job. Do not write functions that combine multiple concerns (e.g., avoid fetchAndTransformUser). Extract compound operations into separate functions.
Functions must have a maximum of 5 parameters. For more than 5 parameters, group related data into a typed options object.
Keep functions short, with a reasonable ceiling of 25–40 lines. Functions should fit on one screen without scrolling.
Every function must return a meaningful value. void return types are forbidden. Use ActionResult for functions with no natural data return.
Recursion must be tail-call or converted to an iterative loop. Non-tail-recursive functions are forbidden in production code because JavaScript engines do not reliably optimize tail calls.
Maximum nesting depth is 2 levels (level 0 is function body, level 1 is a block inside it, level 2 is a block inside that). Extract sub-problems into named functi...

Files:

  • packages/tom-server/src/types.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CODING_STYLE.md)

**/*.{ts,tsx}: Return types must be explicitly annotated on all non-trivial functions in TypeScript. Inference alone is not a contract.
The any type is forbidden without exception in TypeScript. Use a proper type, discriminated union, unknown with a guard, or a generic instead.
Double casts via as unknown as T are forbidden. If the type model is inconsistent, fix the model instead.
Use unknown over any for data from external sources (HTTP responses, JSON.parse, event payloads, database rows). Write a type guard to validate the data.
Prefer type for unions and intersections; prefer interface for object shapes. Keep intent readable through consistent use.
Avoid TypeScript enum. Use string union types for fully internal values. For values from external sources, provide a validation helper that narrows conversion from raw strings.
In TypeScript, caught values have type unknown, not Error. Use instanceof Error checks before accessing Error-specific properties.
Do not use @ts-ignore or @ts-expect-error without an explanatory comment stating the reason and removal condition.

Do not introduce new any types in TypeScript — existing any warnings are tech debt, but new ones are blockers

Files:

  • packages/tom-server/src/types.ts
🧠 Learnings (21)
📓 Common learnings
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/**/*.ts : Use `node-cron` schedule syntax for new jobs in the cron directory
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/**/*.ts : Cron intervals are configured via config keys (e.g., `pepper_cron`, `userdb_cron`)
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/cron/*.ts : Configure cron job intervals via config keys; cron jobs run on server startup
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/matrix-identity-server/src/db/**/*.{ts,js} : `MatrixIdentityServer` initializes two databases: `IdentityServerDb` (identity-server tables) and `UserDB` (user directory)
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Keep Synapse DB schema queries minimal and schema-version-aware to accommodate changes between Synapse versions
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Use matrixDb queries in cron/changePepper.ts to filter active Matrix users when updating hashes
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/user-info-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:38.144Z
Learning: Applies to packages/tom-server/src/user-info-api/user-info-api/**/*.ts : Store visibility settings in the identity server DB (not MatrixDB)
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/changePepper.ts : `changePepper.ts` is a critical job that invalidates all existing hashes and rebuilds them — run carefully
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:51.582Z
Learning: Applies to packages/tom-server/src/identity-server/identity-server/{index.test,with-cache.test}.ts : Write integration tests for TwakeIdentityServer in index.test.ts and cache-enabled lookup behavior in with-cache.test.ts
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:13.313Z
Learning: Applies to packages/tom-server/**/*.{test,spec}.{ts,tsx} : Tests must use SQLite in-memory database and mock external services (SMTP, Matrix homeserver) rather than using real services
📚 Learning: 2026-03-23T09:08:39.061Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/tom-server/src/**/*.{ts,js} : `TwakeServer` extends `MatrixIdentityServer` and adds a second DB connection to the Matrix (Synapse) database via `MatrixDB`

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:23:21.167Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:21.167Z
Learning: Applies to packages/tom-server/src/src/types.ts : Global type definitions and shared interfaces must be defined in `types.ts`

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:23:51.582Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:51.582Z
Learning: Applies to packages/tom-server/src/identity-server/identity-server/index.ts : TwakeIdentityServer should extend MatrixIdentityServer with Twake-specific user lookup and search capabilities

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:24:38.144Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/user-info-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:38.144Z
Learning: Applies to packages/tom-server/src/user-info-api/user-info-api/**/*.ts : Store visibility settings in the identity server DB (not MatrixDB)

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:24:32.491Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/sms-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:32.491Z
Learning: Applies to packages/tom-server/src/sms-api/sms-api/index.ts : Export all public API and types from index.ts in the sms-api module

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:24:48.682Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/wellKnown/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:48.682Z
Learning: Applies to packages/tom-server/src/wellKnown/wellKnown/index.ts : Both `/.well-known/matrix/client` and `/.well-known/twake/client` endpoints should serve identical responses

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:23:35.727Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/admin-settings-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:35.727Z
Learning: Applies to packages/tom-server/src/admin-settings-api/admin-settings-api/**/*.ts : Admin-settings-api module structure should follow the pattern: index.ts for module export, routes/, controllers/, middlewares/, services/, tests/, and types.ts for type definitions

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:20:18.213Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/config-parser/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:18.213Z
Learning: Applies to packages/config-parser/**/*.{ts,tsx} : Define each configuration key's type, default, and required status using the `ConfigDescription` type in twake/config-parser

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:23:13.313Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:13.313Z
Learning: Applies to packages/tom-server/src/config.ts : Document all configuration keys in `src/config.ts` using the `confDesc` object structure

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:20:18.213Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/config-parser/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:18.213Z
Learning: Applies to packages/config-parser/**/*.{ts,tsx} : Supported configuration types in twake/config-parser are: `number`, `boolean`, `array`, `json`, `object`, `string`

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-12T18:28:25.652Z
Learnt from: pm-McFly
Repo: linagora/ToM-server PR: 333
File: packages/tom-server/src/addressbook-api/controllers/index.ts:75-77
Timestamp: 2026-03-12T18:28:25.652Z
Learning: In `packages/tom-server/src/addressbook-api/controllers/index.ts`, the `uid` field from `UserInformation` is intentionally included in the enriched contact response payload (via the `...userInfo` spread). It is a legacy field that was sent before this PR and is planned to be deprecated in a future PR. Do not flag its presence in the response as a bug or security concern during reviews.

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:24:38.144Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/user-info-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:38.144Z
Learning: Applies to packages/tom-server/src/user-info-api/user-info-api/**/*.ts : Ensure the user info API response schema includes: `display_name`, `avatar_url`, `emails`, `phones`, `language`, `timezone`

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:20:10.724Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/common-settings-bridge/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:10.724Z
Learning: Applies to packages/common-settings-bridge/src/src/common-settings-bridge/matrix-profile-updater.ts : Update Matrix user profiles via the homeserver API using the `matrix-profile-updater` module

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-23T09:08:39.061Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/matrix-identity-server/src/db/**/*.{ts,js} : `MatrixIdentityServer` initializes two databases: `IdentityServerDb` (identity-server tables) and `UserDB` (user directory)

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:21:27.917Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:27.917Z
Learning: Applies to packages/matrix-identity-server/src/index.ts : MatrixIdentityServer constructor takes (conf, confDesc?, db?) — conf must include server_name

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:24:48.682Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/wellKnown/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:48.682Z
Learning: Applies to packages/tom-server/src/wellKnown/wellKnown/index.ts : Include response fields for Matrix client auto-discovery: `m.homeserver.base_url`, `m.identity_server.base_url`, `m.integrations`, `org.matrix.msc3575.proxy`, and Jitsi, OIDC, and Twake-specific keys

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:21:40.136Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/index.ts : Register new Matrix Identity Server endpoints in `index.ts` and mount them at `/_matrix/identity/v2/` prefix

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:23:35.727Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/admin-settings-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:35.727Z
Learning: Applies to packages/tom-server/src/admin-settings-api/admin-settings-api/middlewares/**/*.{ts,tsx,js} : Admin token validation middleware must be implemented separately from Matrix authentication to allow machine-to-machine admin operations

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:22:06.022Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/index.ts : Add new identity server tables to the `Collections` enum in `db/index.ts`

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:22:24.131Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Reference configuration keys: matrix_database_engine (pg/sqlite), matrix_database_host, matrix_database_name for database connections

Applied to files:

  • packages/tom-server/src/types.ts
🔇 Additional comments (1)
packages/tom-server/src/types.ts (1)

7-7: Naming convention for handler types is intentional and documented—do not change.

expressAppHandler is a deliberate exception to the PascalCase rule for types. Your codebase explicitly specifies that Express request handlers must use the expressAppHandler type (lowercase), as documented in your learnings. This is consistent with the source definition in @twake/utils and established convention across 40+ usage sites. Renaming it would break a well-established contract that developers rely on.

No change required.


export type PresetConfig = PowerLevelEventContent & { name: string };

export type Content = Record<string, string[] | string | number | boolean | Object>;
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Mar 31, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify whether Content is expected to carry nested arbitrary objects.
rg -n --type=ts -C3 '\bContent\b'

Repository: linagora/ToM-server

Length of output: 29166


🏁 Script executed:

cat -n packages/tom-server/src/types.ts | sed -n '280,310p'

Repository: linagora/ToM-server

Length of output: 556


🏁 Script executed:

rg -n --type=ts 'type Content\b|: Content\b|Content>|as Content' packages/tom-server/src --max-count=20

Repository: linagora/ToM-server

Length of output: 241


🏁 Script executed:

rg -n --type=ts 'StateEvent|CreationContent' packages/tom-server/src -A 2 -B 2 | head -80

Repository: linagora/ToM-server

Length of output: 816


🏁 Script executed:

rg -n --type=ts 'content.*:.*Content|new StateEvent|new CreationContent' packages/tom-server/src

Repository: linagora/ToM-server

Length of output: 504


🏁 Script executed:

rg -n --type=ts 'initial_state|StateEvent.*content' packages/tom-server/src -B 2 -A 3 | head -100

Repository: linagora/ToM-server

Length of output: 8700


🏁 Script executed:

rg -n --type=ts '\bcontent\s*:\s*{|\bcontent\s*=\s*{' packages/tom-server/src --max-count=20

Repository: linagora/ToM-server

Length of output: 197


🏁 Script executed:

rg -n --type=ts 'content.*:' packages/tom-server/src/matrix-api/client/createRoom/tests/service.test.ts | head -20

Repository: linagora/ToM-server

Length of output: 373


🏁 Script executed:

rg -n --type=ts 'content:\s*\{' packages/tom-server/src -B 1 -A 5

Repository: linagora/ToM-server

Length of output: 11106


🏁 Script executed:

rg -n --type=ts 'content.*Record|nested.*content' packages/tom-server/src

Repository: linagora/ToM-server

Length of output: 45


🏁 Script executed:

# Check if there are any examples with nested objects in content
rg -n --type=ts -A 10 'content:\s*\{' packages/tom-server/src/matrix-api/client/createRoom/tests/service.test.ts | grep -E 'content:|^\s+[a-zA-Z]+:' | head -40

Repository: linagora/ToM-server

Length of output: 235


🏁 Script executed:

# Final verification: check if there's any TypeScript compilation error with the proposed fix
cat > /tmp/test_content_type.ts << 'EOF'
// Proposed types
export type ContentValue = string[] | string | number | boolean | Record<string, unknown>;
export type Content = Record<string, ContentValue>;

// Original types
export type ContentOld = Record<string, string[] | string | number | boolean | Object>;

// Test assignments
const example1: Content = { name: 'Test Room' };
const example2: Content = { algorithm: 'm.megolm.v1.aes-sha2' };
const example3: Content = { body: 'message 1' };
const example4: Content = { sub: 'userId', epoch: 1 };
const example5: Content = { nested: { deep: { value: 'test' } } }; // recursive check

// StateEvent usage
interface StateEvent {
  content: Content;
  state_key?: string;
  type: string;
}

const event: StateEvent = {
  type: 'm.room.encryption',
  state_key: '',
  content: { algorithm: 'm.megolm.v1.aes-sha2' }
};
EOF
cat /tmp/test_content_type.ts

Repository: linagora/ToM-server

Length of output: 886


Replace Object with unknown in the Content type definition.

The Object type is a type-safety hole—it accepts anything and gives you zero compile-time guarantees. This violates the project's strictness rules around external data handling. Replace it with a proper recursive type using unknown:

Proposed fix
-export type Content = Record<string, string[] | string | number | boolean | Object>;
+export type ContentValue = string[] | string | number | boolean | Record<string, unknown>;
+export type Content = Record<string, ContentValue>;

This change keeps the recursive structure needed for Matrix protocol event content while enforcing type safety at the boundary.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@coderabbitai you got a valid point but this is outside of this PR scope

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@pm-McFly Understood, no problem — this PR is focused on quota removal and that's the right scope boundary. Would you like me to open a follow-up issue to track replacing Object with unknown (or a proper recursive type) in the Content type definition in packages/tom-server/src/types.ts?


🧠 Learnings used
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/tom-server/src/**/*.{ts,js} : `TwakeServer` extends `MatrixIdentityServer` and adds a second DB connection to the Matrix (Synapse) database via `MatrixDB`

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/user-info-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:38.144Z
Learning: Applies to packages/tom-server/src/user-info-api/user-info-api/**/*.ts : Store visibility settings in the identity server DB (not MatrixDB)

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/tom-server/src/types.ts : See `packages/tom-server/src/types.ts` (`Config` type) for all configuration options

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:51.582Z
Learning: Applies to packages/tom-server/src/identity-server/identity-server/index.ts : TwakeIdentityServer should extend MatrixIdentityServer with Twake-specific user lookup and search capabilities

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/matrix-identity-server/src/db/**/*.{ts,js} : `MatrixIdentityServer` initializes two databases: `IdentityServerDb` (identity-server tables) and `UserDB` (user directory)

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/admin-settings-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:35.727Z
Learning: Applies to packages/tom-server/src/admin-settings-api/admin-settings-api/middlewares/**/*.{ts,tsx,js} : Admin token validation middleware must be implemented separately from Matrix authentication to allow machine-to-machine admin operations

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/wellKnown/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:48.682Z
Learning: Applies to packages/tom-server/src/wellKnown/wellKnown/index.ts : Both `/.well-known/matrix/client` and `/.well-known/twake/client` endpoints should serve identical responses

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:21.167Z
Learning: Applies to packages/tom-server/src/src/types.ts : Global type definitions and shared interfaces must be defined in `types.ts`

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/wellKnown/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:48.682Z
Learning: Applies to packages/tom-server/src/wellKnown/wellKnown/index.ts : Include response fields for Matrix client auto-discovery: `m.homeserver.base_url`, `m.identity_server.base_url`, `m.integrations`, `org.matrix.msc3575.proxy`, and Jitsi, OIDC, and Twake-specific keys

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/sms-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:32.491Z
Learning: Applies to packages/tom-server/src/sms-api/sms-api/types.ts : Define request and response type definitions for the SMS API endpoint in types.ts, including phone number format and SMS response structure

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{ts,tsx} : Use `unknown` over `any` for data from external sources (HTTP responses, `JSON.parse`, event payloads, database rows). Write a type guard to validate the data.

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{ts,tsx} : The `any` type is forbidden without exception in TypeScript. Use a proper type, discriminated union, `unknown` with a guard, or a generic instead.

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{ts,tsx} : Double casts via `as unknown as T` are forbidden. If the type model is inconsistent, fix the model instead.

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-03-27T16:21:28.793Z
Learning: Applies to **/*.{ts,tsx} : Do not introduce new `any` types in TypeScript — existing `any` warnings are tech debt, but new ones are blockers

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{ts,tsx} : In TypeScript, caught values have type `unknown`, not `Error`. Use `instanceof Error` checks before accessing Error-specific properties.

Learnt from: pm-McFly
Repo: linagora/ToM-server PR: 341
File: biome.json:94-94
Timestamp: 2026-03-18T21:38:15.357Z
Learning: In linagora/ToM-server, the `noEnum: "warn"` rule in `biome.json` is intentional. The linting pipeline is expected to fail temporarily while existing `enum` declarations (e.g., `ETransportType`, `ProfileField`, `ProfileVisibility`, `SMS_FOOTERS`, `SynapseAdminRetryMode`, `ConnectionState`) are progressively replaced with string unions and runtime type guards, as prescribed in CODING_STYLE.md. This is a deliberate enforcement strategy, not an oversight.

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{ts,tsx} : Avoid TypeScript `enum`. Use string union types for fully internal values. For values from external sources, provide a validation helper that narrows conversion from raw strings.

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Keep Synapse DB schema queries minimal and schema-version-aware to accommodate changes between Synapse versions

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/wellKnown/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:48.682Z
Learning: Applies to packages/tom-server/src/wellKnown/wellKnown/**/*.ts : When adding new config fields to well-known responses, update `src/config.json` (in tom-server) first, then include the value in the response object in the wellKnown directory

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/admin-settings-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:35.727Z
Learning: Applies to packages/tom-server/src/admin-settings-api/admin-settings-api/**/*.ts : Admin-settings-api module structure should follow the pattern: index.ts for module export, routes/, controllers/, middlewares/, services/, tests/, and types.ts for type definitions

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:13.313Z
Learning: Applies to packages/tom-server/src/config.ts : Document all configuration keys in `src/config.ts` using the `confDesc` object structure

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/tom-server/src/**/*.{ts,js} : Feature API modules follow a consistent pattern: `routes/` → `controllers/` → `services/` with `middlewares/` and `types.ts`

Learnt from: pm-McFly
Repo: linagora/ToM-server PR: 355
File: packages/matrix-identity-server/src/db/index.ts:413-413
Timestamp: 2026-03-31T07:26:27.898Z
Learning: When reviewing TypeScript code in this repo, follow Biome’s `noDoubleEquals` rule: do not use loose equality (`== null` / `!= null`) as a shorthand. For nullish checks, use explicit strict comparisons instead (e.g., `value === null || value === undefined` or `value !== null && value !== undefined`).

Signed-off-by: Pierre 'McFly' Marty <pmarty@linagora.com>
Signed-off-by: Pierre 'McFly' Marty <pmarty@linagora.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (1)
packages/tom-server/src/types.ts (1)

293-293: ⚠️ Potential issue | 🟠 Major

Object type is a type-safety black hole — previous review flagged this.

A past review comment specifically called this out and proposed a fix. The Object type accepts literally anything and provides zero compile-time guarantees. This violates your own coding guidelines about any being forbidden.

🔧 Proposed fix from previous review
-export type Content = Record<string, string[] | string | number | boolean | Object>;
+export type ContentValue = string[] | string | number | boolean | Record<string, unknown>;
+export type Content = Record<string, ContentValue>;

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a85c6826-7f35-42d5-b9ab-cd2ebbe908f9

📥 Commits

Reviewing files that changed from the base of the PR and between 5d3a504 and 81cd5d9.

📒 Files selected for processing (5)
  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
  • packages/tom-server/src/types.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test / Test Affected Packages
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{ts,tsx,js,jsx,json,md}

📄 CodeRabbit inference engine (CLAUDE.md)

Use npm run format:check and npm run format:fix for code formatting checks

Files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
  • packages/tom-server/src/types.ts
packages/matrix-identity-server/src/**/*.{ts,js}

📄 CodeRabbit inference engine (CLAUDE.md)

Routes are registered on this.api.get and this.api.post maps and mounted by the parent server

Files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (CODING_STYLE.md)

**/*.{js,ts,jsx,tsx}: Use 2 spaces for indentation, not 4, tabs, or other amounts. Enforce with a formatter.
Opening braces must go on the same line. Never place opening braces on a new line.
Use trailing commas in multi-line structures (arrays, objects, function parameters) to minimize diff noise.
Semicolons are required on all statements. Do not rely on Automatic Semicolon Insertion (ASI).
Enforce a hard line length limit of 120 characters. Break overly complex expressions into named sub-expressions.
Use camelCase for variable and function names.
Use PascalCase for types, interfaces, classes, and enums.
Use SCREAMING_SNAKE_CASE only for module-level primitives that are truly constant and never change. Do not use for local bindings.
Boolean variables must read as a question using prefixes like is, has, can (e.g., isLoading, hasPermission, canRetry). Never use bare noun forms.
Do not abbreviate variable or function names except for: i, j in tight loops; e for event parameters; err for errors; ctx for context; req/res in HTTP handlers.
Each function must do exactly one job. Do not write functions that combine multiple concerns (e.g., avoid fetchAndTransformUser). Extract compound operations into separate functions.
Functions must have a maximum of 5 parameters. For more than 5 parameters, group related data into a typed options object.
Keep functions short, with a reasonable ceiling of 25–40 lines. Functions should fit on one screen without scrolling.
Every function must return a meaningful value. void return types are forbidden. Use ActionResult for functions with no natural data return.
Recursion must be tail-call or converted to an iterative loop. Non-tail-recursive functions are forbidden in production code because JavaScript engines do not reliably optimize tail calls.
Maximum nesting depth is 2 levels (level 0 is function body, level 1 is a block inside it, level 2 is a block inside that). Extract sub-problems into named functi...

Files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
  • packages/tom-server/src/types.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CODING_STYLE.md)

**/*.{ts,tsx}: Return types must be explicitly annotated on all non-trivial functions in TypeScript. Inference alone is not a contract.
The any type is forbidden without exception in TypeScript. Use a proper type, discriminated union, unknown with a guard, or a generic instead.
Double casts via as unknown as T are forbidden. If the type model is inconsistent, fix the model instead.
Use unknown over any for data from external sources (HTTP responses, JSON.parse, event payloads, database rows). Write a type guard to validate the data.
Prefer type for unions and intersections; prefer interface for object shapes. Keep intent readable through consistent use.
Avoid TypeScript enum. Use string union types for fully internal values. For values from external sources, provide a validation helper that narrows conversion from raw strings.
In TypeScript, caught values have type unknown, not Error. Use instanceof Error checks before accessing Error-specific properties.
Do not use @ts-ignore or @ts-expect-error without an explanatory comment stating the reason and removal condition.

Do not introduce new any types in TypeScript — existing any warnings are tech debt, but new ones are blockers

Files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
  • packages/tom-server/src/types.ts
packages/matrix-identity-server/src/db/**/*.{ts,js}

📄 CodeRabbit inference engine (CLAUDE.md)

MatrixIdentityServer initializes two databases: IdentityServerDb (identity-server tables) and UserDB (user directory)

Files:

  • packages/matrix-identity-server/src/db/index.ts
packages/tom-server/**/*.{ts,tsx}

📄 CodeRabbit inference engine (packages/tom-server/AGENTS.md)

packages/tom-server/**/*.{ts,tsx}: TwakeServer constructor requires conf parameter with mandatory server_name and base_url properties
Mount TwakeServer endpoints by accessing this.endpoints (Express Router) and using app.use('/', server.endpoints)
Await the this.ready Promise before handling requests to ensure DB, key generation, and all services are initialized

Files:

  • packages/tom-server/src/types.ts
packages/tom-server/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (packages/tom-server/AGENTS.md)

Pass singleton services (AddressbookService, UserInfoService, TokenService, SmsService) created in _initServer() to API modules via dependency injection

Files:

  • packages/tom-server/src/types.ts
packages/tom-server/src/**/*.{ts,js}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/tom-server/src/**/*.{ts,js}: TwakeServer extends MatrixIdentityServer and adds a second DB connection to the Matrix (Synapse) database via MatrixDB
Feature API modules follow a consistent pattern: routes/controllers/services/ with middlewares/ and types.ts

Files:

  • packages/tom-server/src/types.ts
packages/tom-server/src/types.ts

📄 CodeRabbit inference engine (CLAUDE.md)

See packages/tom-server/src/types.ts (Config type) for all configuration options

Files:

  • packages/tom-server/src/types.ts
🧠 Learnings (75)
📓 Common learnings
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/**/*.ts : Use `node-cron` schedule syntax for new jobs in the cron directory
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/**/*.ts : Cron intervals are configured via config keys (e.g., `pepper_cron`, `userdb_cron`)
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/cron/*.ts : Configure cron job intervals via config keys; cron jobs run on server startup
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/matrix-identity-server/src/db/**/*.{ts,js} : `MatrixIdentityServer` initializes two databases: `IdentityServerDb` (identity-server tables) and `UserDB` (user directory)
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Keep Synapse DB schema queries minimal and schema-version-aware to accommodate changes between Synapse versions
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Use matrixDb queries in cron/changePepper.ts to filter active Matrix users when updating hashes
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/user-info-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:38.144Z
Learning: Applies to packages/tom-server/src/user-info-api/user-info-api/**/*.ts : Store visibility settings in the identity server DB (not MatrixDB)
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:51.582Z
Learning: Applies to packages/tom-server/src/identity-server/identity-server/{index.test,with-cache.test}.ts : Write integration tests for TwakeIdentityServer in index.test.ts and cache-enabled lookup behavior in with-cache.test.ts
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/changePepper.ts : `changePepper.ts` is a critical job that invalidates all existing hashes and rebuilds them — run carefully
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/metrics-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:13.473Z
Learning: Applies to packages/tom-server/src/metrics-api/**/metrics-api/services/**/*.ts : Services in metrics-api must query the Matrix (Synapse) database directly, not the identity server DB
📚 Learning: 2026-03-17T11:21:55.851Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/**/*.ts : Use `node-cron` schedule syntax for new jobs in the cron directory

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:21:55.851Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/**/*.ts : Cron intervals are configured via config keys (e.g., `pepper_cron`, `userdb_cron`)

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:21:40.136Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/cron/*.ts : Configure cron job intervals via config keys; cron jobs run on server startup

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:21:55.851Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/changePepper.ts : `changePepper.ts` is a critical job that invalidates all existing hashes and rebuilds them — run carefully

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
📚 Learning: 2026-03-17T11:22:24.131Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Use matrixDb queries in cron/changePepper.ts to filter active Matrix users when updating hashes

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
📚 Learning: 2026-03-17T11:22:24.131Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Keep Synapse DB schema queries minimal and schema-version-aware to accommodate changes between Synapse versions

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-23T09:08:39.061Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/matrix-identity-server/src/db/**/*.{ts,js} : `MatrixIdentityServer` initializes two databases: `IdentityServerDb` (identity-server tables) and `UserDB` (user directory)

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:20:10.724Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/common-settings-bridge/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:10.724Z
Learning: Applies to packages/common-settings-bridge/src/src/common-settings-bridge/matrix-profile-updater.ts : Update Matrix user profiles via the homeserver API using the `matrix-profile-updater` module

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:22:24.131Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/**/*.ts : Never write to Synapse tables from the matrixDb module — implement read-only access to the Matrix homeserver (Synapse) database

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
📚 Learning: 2026-03-17T11:22:12.102Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/keyManagement/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:12.102Z
Learning: Applies to packages/matrix-identity-server/src/keyManagement/keyManagement/**/*.ts : Use Ed25519 for public key management in the Matrix Identity Server

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-27T16:21:10.935Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : When wrapping a caught error and rethrowing, always use `Error.cause` to preserve the original error's stack trace and context.

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-27T16:21:10.935Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Never swallow errors silently. Always log with context or rethrow. Empty `catch` blocks are forbidden.

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-27T16:21:10.935Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Never fire-and-forget async operations without attaching a `.catch()` handler to acknowledge and handle potential rejections.

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-27T16:21:10.935Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Place `try/catch` at system boundaries (HTTP handlers, job runners, event listeners, CLI entry points), not deep in business logic.

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:23:51.582Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:51.582Z
Learning: Applies to packages/tom-server/src/identity-server/identity-server/index.ts : TwakeIdentityServer must add twakeDbCollections to extend the identity server database schema

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:35.300Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/crypto/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:35.300Z
Learning: Applies to packages/crypto/**/*.{ts,tsx} : In the `twake/crypto` package, the `Hash` class requires async initialization via `await hash.ready` before calling `.sha256()` or `.sha512()`

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
📚 Learning: 2026-03-17T11:22:18.337Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/lookup/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:18.337Z
Learning: Applies to packages/matrix-identity-server/src/lookup/lookup/updateHash.ts : Use generic-pool for concurrency control with a worker pool limit of 5 workers in updateHash.ts during pepper rotation

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
📚 Learning: 2026-03-17T11:22:18.337Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/lookup/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:18.337Z
Learning: Pepper should be stored in the database and rotated by the cron/changePepper.ts job

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
📚 Learning: 2026-03-17T11:21:16.677Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/logger/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:16.677Z
Learning: Applies to packages/logger/**/*.{ts,tsx} : Use `getLogger(conf?, confDesc?)` as the main factory function to obtain a Winston `Logger` instance typed as `TwakeLogger`

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
📚 Learning: 2026-03-17T11:21:16.677Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/logger/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:16.677Z
Learning: Applies to packages/logger/**/*.{ts,tsx} : Type dependency-injected logger instances as `TwakeLogger` type alias for Winston's `Logger`

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
📚 Learning: 2026-03-17T11:21:16.677Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/logger/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:16.677Z
Learning: Applies to packages/logger/src/index.ts : The main export file `src/index.ts` must export: `getLogger()`, `ETransportType`, `Config` type, and `TwakeLogger` type

Applied to files:

  • packages/matrix-identity-server/src/cron/index.ts
  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:23:13.313Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:13.313Z
Learning: Applies to packages/tom-server/**/*.{test,spec}.{ts,tsx} : Tests must use SQLite in-memory database and mock external services (SMTP, Matrix homeserver) rather than using real services

Applied to files:

  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:20:10.724Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/common-settings-bridge/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:10.724Z
Learning: Applies to packages/common-settings-bridge/src/src/common-settings-bridge/**/*.test.ts : Mock the `matrix-appservice-bridge` library in Jest tests using the mock in `__mocks__/matrix-appservice-bridge.ts`

Applied to files:

  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:23:51.582Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:51.582Z
Learning: Applies to packages/tom-server/src/identity-server/identity-server/{index.test,with-cache.test}.ts : Write integration tests for TwakeIdentityServer in index.test.ts and cache-enabled lookup behavior in with-cache.test.ts

Applied to files:

  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:22:24.131Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Support both PostgreSQL and SQLite Synapse configurations with driver-specific queries

Applied to files:

  • packages/matrix-identity-server/src/cron/index.test.ts
  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-23T09:08:39.061Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to **/jest.config.{ts,js} : Tests use Jest + ts-jest and `testcontainers` for spinning up real PostgreSQL/LDAP in CI

Applied to files:

  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:20:46.846Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:46.846Z
Learning: Applies to packages/db/**/*.test.{ts,tsx} : Use SQLite in-memory database for test isolation in twake/db tests

Applied to files:

  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:21:16.677Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/logger/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:16.677Z
Learning: Run tests using `npx nx run twake/logger:test`

Applied to files:

  • packages/matrix-identity-server/src/cron/index.test.ts
📚 Learning: 2026-03-17T11:22:06.022Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/sql/{pg,sqlite}.ts : When adding a new table, define schema in `db/index.ts`, and add SQL implementations in both `db/sql/pg.ts` (PostgreSQL) and `db/sql/sqlite.ts` (SQLite)

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:22:24.131Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Reference configuration keys: matrix_database_engine (pg/sqlite), matrix_database_host, matrix_database_name for database connections

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:21:40.136Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/userdb/*.ts : Select userdb backend via `user_db` config key: `sqlite`, `pg`, `ldap`, or empty string

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:22:06.022Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/index.ts : Add new identity server tables to the `Collections` enum in `db/index.ts`

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:22:06.022Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/**/*.ts : All SQL queries must use parameterized statements — never string-interpolate user input into SQL

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:21:40.136Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/db/index.ts : Add new database table names to the `Collections` enum in `db/index.ts`

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:21:27.917Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:27.917Z
Learning: Applies to packages/matrix-identity-server/src/index.ts : The db property exposes the identity server's database for subclass use

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:21:27.917Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:27.917Z
Learning: Applies to packages/matrix-identity-server/src/index.ts : this.ready is a Promise that resolves when async initialization (key gen, DB setup) completes

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:56.983Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/index.ts : In `db/src/index.ts`, export the main `Database` class, `Pg`, `SQLite`, and `createTables` function

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:56.983Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/database.ts : In `db/src/database.ts`, implement the `Database` base class for connection management and query interface

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:56.983Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/_createTables.ts : In `db/src/sql/_createTables.ts`, implement `createTables()` function to create tables from schema definitions if they don't exist

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:46.846Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:46.846Z
Learning: Applies to packages/db/src/index.ts : Export `Database` class, adapter implementations (`Pg`, `SQLite`), `createTables` function, and column/condition types from `src/index.ts` in twake/db

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:56.983Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/sql.ts : In `db/src/sql/sql.ts`, implement base SQL utilities and shared query logic

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:22:24.131Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Implement query methods getAll(), get(), and match() in the MatrixDB class for querying Synapse tables

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:56.983Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/types.ts : In `db/src/types.ts`, define column definitions, condition operators, and table schema types

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:21:45.978Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/account/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:45.978Z
Learning: Applies to packages/matrix-identity-server/src/account/account/{register,logout}.ts : Access tokens are stored in the `accessTokens` DB collection

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:23:13.313Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:13.313Z
Learning: Applies to packages/tom-server/**/*.{ts,tsx} : Await the `this.ready` Promise before handling requests to ensure DB, key generation, and all services are initialized

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:21:45.978Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/account/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:45.978Z
Learning: Applies to packages/matrix-identity-server/src/account/account/logout.ts : POST `/_matrix/identity/v2/account/logout` endpoint deletes the current access token from DB

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:22:12.102Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/keyManagement/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:12.102Z
Learning: Applies to packages/matrix-identity-server/src/keyManagement/keyManagement/**/*.ts : Use `keyId` format of `ed25519:<base64url-encoded-public-key>` for identifying keys

Applied to files:

  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:21:27.917Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:27.917Z
Learning: Applies to packages/matrix-identity-server/src/{account,3pid,lookup,terms,validate,keyManagement}/**/*.ts : All spec endpoints should be mounted at /_matrix/identity/v2/

Applied to files:

  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:22:38.835Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/userdb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:38.835Z
Learning: Applies to packages/matrix-identity-server/src/userdb/userdb/**/*.ts : All backends in the userdb module must implement the same interface with methods `get()`, `getAll()`, and `match()` for querying user information

Applied to files:

  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:22:45.233Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/utils/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:45.233Z
Learning: Applies to packages/matrix-identity-server/src/utils/**/utils/mailer.ts : SMTP configuration in `mailer.ts` should use keys: `smtp_server`, `smtp_port`, `smtp_user`, `smtp_password`, `smtp_tls`

Applied to files:

  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-17T11:20:10.724Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/common-settings-bridge/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:10.724Z
Learning: Applies to packages/common-settings-bridge/src/src/common-settings-bridge/types.ts : Use TypeScript type definitions in `types.ts` for bridge configuration and events

Applied to files:

  • packages/matrix-identity-server/src/types.ts
  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:23:21.167Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:21.167Z
Learning: Applies to packages/tom-server/src/src/types.ts : Global type definitions and shared interfaces must be defined in `types.ts`

Applied to files:

  • packages/matrix-identity-server/src/types.ts
  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:21:27.917Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:27.917Z
Learning: Applies to packages/matrix-identity-server/src/index.ts : MatrixIdentityServer constructor takes (conf, confDesc?, db?) — conf must include server_name

Applied to files:

  • packages/matrix-identity-server/src/types.ts
  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:24:32.491Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/sms-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:32.491Z
Learning: Applies to packages/tom-server/src/sms-api/sms-api/types.ts : Define request and response type definitions for the SMS API endpoint in types.ts, including phone number format and SMS response structure

Applied to files:

  • packages/matrix-identity-server/src/types.ts
📚 Learning: 2026-03-23T09:08:39.061Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/tom-server/src/**/*.{ts,js} : `TwakeServer` extends `MatrixIdentityServer` and adds a second DB connection to the Matrix (Synapse) database via `MatrixDB`

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:24:48.682Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/wellKnown/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:48.682Z
Learning: Applies to packages/tom-server/src/wellKnown/wellKnown/index.ts : Both `/.well-known/matrix/client` and `/.well-known/twake/client` endpoints should serve identical responses

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:23:51.582Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:51.582Z
Learning: Applies to packages/tom-server/src/identity-server/identity-server/index.ts : TwakeIdentityServer should extend MatrixIdentityServer with Twake-specific user lookup and search capabilities

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:24:48.682Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/wellKnown/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:48.682Z
Learning: Applies to packages/tom-server/src/wellKnown/wellKnown/index.ts : Include response fields for Matrix client auto-discovery: `m.homeserver.base_url`, `m.identity_server.base_url`, `m.integrations`, `org.matrix.msc3575.proxy`, and Jitsi, OIDC, and Twake-specific keys

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:24:38.144Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/user-info-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:38.144Z
Learning: Applies to packages/tom-server/src/user-info-api/user-info-api/**/*.ts : Store visibility settings in the identity server DB (not MatrixDB)

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:19:52.544Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/amqp-connector/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:19:52.544Z
Learning: Applies to packages/amqp-connector/src/amqp-connector/src/types.ts : Type definitions for AmqpConfig, ReconnectionConfig, MessageHandler, and ConnectionState should be maintained in types.ts

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:20:18.213Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/config-parser/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:18.213Z
Learning: Applies to packages/config-parser/**/*.{ts,tsx} : Supported configuration types in twake/config-parser are: `number`, `boolean`, `array`, `json`, `object`, `string`

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-12T18:28:25.652Z
Learnt from: pm-McFly
Repo: linagora/ToM-server PR: 333
File: packages/tom-server/src/addressbook-api/controllers/index.ts:75-77
Timestamp: 2026-03-12T18:28:25.652Z
Learning: In `packages/tom-server/src/addressbook-api/controllers/index.ts`, the `uid` field from `UserInformation` is intentionally included in the enriched contact response payload (via the `...userInfo` spread). It is a legacy field that was sent before this PR and is planned to be deprecated in a future PR. Do not flag its presence in the response as a bug or security concern during reviews.

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:24:38.144Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/user-info-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:38.144Z
Learning: Applies to packages/tom-server/src/user-info-api/user-info-api/**/*.ts : Ensure the user info API response schema includes: `display_name`, `avatar_url`, `emails`, `phones`, `language`, `timezone`

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-27T16:21:10.935Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{ts,tsx} : Use `unknown` over `any` for data from external sources (HTTP responses, `JSON.parse`, event payloads, database rows). Write a type guard to validate the data.

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-27T16:21:10.935Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{ts,tsx} : The `any` type is forbidden without exception in TypeScript. Use a proper type, discriminated union, `unknown` with a guard, or a generic instead.

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-27T16:21:10.935Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{ts,tsx} : Double casts via `as unknown as T` are forbidden. If the type model is inconsistent, fix the model instead.

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-27T16:21:10.935Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{ts,tsx} : In TypeScript, caught values have type `unknown`, not `Error`. Use `instanceof Error` checks before accessing Error-specific properties.

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-27T16:21:28.793Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-03-27T16:21:28.793Z
Learning: Applies to **/*.{ts,tsx} : Do not introduce new `any` types in TypeScript — existing `any` warnings are tech debt, but new ones are blockers

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-27T16:21:10.935Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{ts,tsx} : Avoid TypeScript `enum`. Use string union types for fully internal values. For values from external sources, provide a validation helper that narrows conversion from raw strings.

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-27T16:21:10.935Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{ts,tsx} : Prefer `type` for unions and intersections; prefer `interface` for object shapes. Keep intent readable through consistent use.

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-18T21:38:15.357Z
Learnt from: pm-McFly
Repo: linagora/ToM-server PR: 341
File: biome.json:94-94
Timestamp: 2026-03-18T21:38:15.357Z
Learning: In linagora/ToM-server, the `noEnum: "warn"` rule in `biome.json` is intentional. The linting pipeline is expected to fail temporarily while existing `enum` declarations (e.g., `ETransportType`, `ProfileField`, `ProfileVisibility`, `SMS_FOOTERS`, `SynapseAdminRetryMode`, `ConnectionState`) are progressively replaced with string unions and runtime type guards, as prescribed in CODING_STYLE.md. This is a deliberate enforcement strategy, not an oversight.

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-27T16:21:10.935Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{ts,tsx} : Return types must be explicitly annotated on all non-trivial functions in TypeScript. Inference alone is not a contract.

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:23:35.727Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/admin-settings-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:35.727Z
Learning: Applies to packages/tom-server/src/admin-settings-api/admin-settings-api/middlewares/**/*.{ts,tsx,js} : Admin token validation middleware must be implemented separately from Matrix authentication to allow machine-to-machine admin operations

Applied to files:

  • packages/tom-server/src/types.ts
📚 Learning: 2026-03-17T11:21:40.136Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/index.ts : Register new Matrix Identity Server endpoints in `index.ts` and mount them at `/_matrix/identity/v2/` prefix

Applied to files:

  • packages/tom-server/src/types.ts
🪛 Biome (2.4.9)
packages/matrix-identity-server/src/db/index.ts

[error] 109-116: Function has 6 parameters, but only 5 are allowed.

(lint/complexity/useMaxParams)


[error] 117-125: Function has 7 parameters, but only 5 are allowed.

(lint/complexity/useMaxParams)


[error] 144-144: Unexpected any. Specify a different type.

(lint/suspicious/noExplicitAny)


[error] 182-182: This variable implicitly has the any type.

(lint/suspicious/noImplicitAnyLet)

packages/matrix-identity-server/src/types.ts

[error] 31-31: Unexpected any. Specify a different type.

(lint/suspicious/noExplicitAny)

🔇 Additional comments (6)
packages/matrix-identity-server/src/types.ts (1)

1-66: Formatting normalization looks clean.

The import type conversions and semicolon additions align with the codebase style. No functional changes here.

The any on line 31 (ldapts_opts?: Record<string, any>) is pre-existing tech debt, not introduced by this PR. Static analysis is right to flag it, but it's not your mess to clean up in a quota-removal PR.

packages/matrix-identity-server/src/db/index.ts (1)

684-696: Existing setTimeout concerns are pre-existing and already flagged.

The past review comments about setTimeout with potentially untrusted data at lines 694/696 are pre-existing issues, not introduced by this PR. The formatting changes here are fine.

packages/matrix-identity-server/src/cron/index.ts (2)

40-54: Quota job removal is clean.

The _addCheckUserQuotaJob method and its invocation have been properly removed. The remaining cron initialization logic is correct:

  • Hash updates job (always)
  • Federated identity hashes job (when federated_identity_services is configured)

The null check on line 45 is correct (&& && &&), unlike the mess in db/index.ts.


130-133: Catch block now properly omits unused binding.

Good - you've addressed the previous review comment about the unused error variable. The bare catch is correct here since you're rethrowing with a generic message anyway.

packages/matrix-identity-server/src/cron/index.test.ts (1)

77-81: Test expectation correctly updated for quota removal.

The task count going from 4 to 3 matches the removal of _addCheckUserQuotaJob. With federated_identity_services configured, you get:

  1. updateHashesTask
  2. updateUsersTask
  3. federatedIdentityUpdates

Math checks out.

packages/tom-server/src/types.ts (1)

1-8: Import reorganization looks good.

The import type conversions and semicolon additions follow the project style. Clean.

Comment on lines +49 to +51
} catch {
reject(Error("Failed to initialize test database"));
}
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Mar 31, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Still using Error() without new.

Past review comment claimed this was addressed, but line 50 still shows reject(Error("Failed to initialize test database")). Fix it:

🔧 Proposed fix
         } catch {
-          reject(Error("Failed to initialize test database"));
+          reject(new Error("Failed to initialize test database"));
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} catch {
reject(Error("Failed to initialize test database"));
}
} catch {
reject(new Error("Failed to initialize test database"));
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@coderabbitai you got a valid point but this is outside of this PR scope

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@pm-McFly, understood — acknowledged and moving on. Would you like me to open a follow-up GitHub issue to track the new Error(...) fix so it doesn't get lost?


🧠 Learnings used
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/cron/*.ts : Configure cron job intervals via config keys; cron jobs run on server startup

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/**/*.ts : Cron intervals are configured via config keys (e.g., `pepper_cron`, `userdb_cron`)

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/matrix-identity-server/src/db/**/*.{ts,js} : `MatrixIdentityServer` initializes two databases: `IdentityServerDb` (identity-server tables) and `UserDB` (user directory)

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:13.313Z
Learning: Applies to packages/tom-server/**/*.{test,spec}.{ts,tsx} : Tests must use SQLite in-memory database and mock external services (SMTP, Matrix homeserver) rather than using real services

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:46.846Z
Learning: Applies to packages/db/**/*.test.{ts,tsx} : Use SQLite in-memory database for test isolation in twake/db tests

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/**/*.ts : Use `node-cron` schedule syntax for new jobs in the cron directory

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:51.582Z
Learning: Applies to packages/tom-server/src/identity-server/identity-server/{index.test,with-cache.test}.ts : Write integration tests for TwakeIdentityServer in index.test.ts and cache-enabled lookup behavior in with-cache.test.ts

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Support both PostgreSQL and SQLite Synapse configurations with driver-specific queries

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Reference configuration keys: matrix_database_engine (pg/sqlite), matrix_database_host, matrix_database_name for database connections

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Keep Synapse DB schema queries minimal and schema-version-aware to accommodate changes between Synapse versions

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : When wrapping a caught error and rethrowing, always use `Error.cause` to preserve the original error's stack trace and context.

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to **/jest.config.{ts,js} : Tests use Jest + ts-jest and `testcontainers` for spinning up real PostgreSQL/LDAP in CI

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to **/tests/**/*.{ts,js} : Tests run with `LOG_TRANSPORTS=File LOG_FILE=/dev/null jest` to suppress log output

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/amqp-connector/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:19:52.544Z
Learning: Applies to packages/amqp-connector/src/amqp-connector/src/index.test.ts : Jest tests in index.test.ts must mock amqplib and cover connection lifecycle, reconnection, and error handling scenarios

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-resolve/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:57.617Z
Learning: Applies to packages/matrix-resolve/**/*.test.ts : Mock `node-fetch` and DNS in tests — no network calls required for test execution

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/sqlite.ts : In `db/src/sql/sqlite.ts`, implement SQLite adapter using `sqlite3` or `better-sqlite3`

Learnt from: pm-McFly
Repo: linagora/ToM-server PR: 355
File: packages/matrix-identity-server/src/db/index.ts:413-413
Timestamp: 2026-03-31T07:26:27.898Z
Learning: When reviewing TypeScript code in this repo, follow Biome’s `noDoubleEquals` rule: do not use loose equality (`== null` / `!= null`) as a shorthand. For nullish checks, use explicit strict comparisons instead (e.g., `value === null || value === undefined` or `value !== null && value !== undefined`).

this.cleanByExpires = cleanByExpires
let Module
this.cleanByExpires = cleanByExpires;
let Module;
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Mar 31, 2026

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Implicit any on Module variable.

Static analysis correctly flags this. Type it properly:

🧹 Proposed fix
-    let Module;
+    let Module: typeof Sqlite | typeof Pg;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let Module;
let Module: typeof SQLite | typeof Pg;
🧰 Tools
🪛 Biome (2.4.9)

[error] 182-182: This variable implicitly has the any type.

(lint/suspicious/noImplicitAnyLet)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@coderabbitai you got a valid point but this is outside of this PR scope

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@pm-McFly Fair enough — quota removal is the mission here, and dragging in unrelated typing fixes muddies the diff. Would you like me to open a follow-up issue to track the Module implicit any typing fix in packages/matrix-identity-server/src/db/index.ts?


🧠 Learnings used
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/matrix-identity-server/src/db/**/*.{ts,js} : `MatrixIdentityServer` initializes two databases: `IdentityServerDb` (identity-server tables) and `UserDB` (user directory)

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Reference configuration keys: matrix_database_engine (pg/sqlite), matrix_database_host, matrix_database_name for database connections

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/index.ts : Add new identity server tables to the `Collections` enum in `db/index.ts`

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/sql/{pg,sqlite}.ts : When adding a new table, define schema in `db/index.ts`, and add SQL implementations in both `db/sql/pg.ts` (PostgreSQL) and `db/sql/sqlite.ts` (SQLite)

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/db/index.ts : Add new database table names to the `Collections` enum in `db/index.ts`

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:27.917Z
Learning: Applies to packages/matrix-identity-server/src/index.ts : The db property exposes the identity server's database for subclass use

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:51.582Z
Learning: Applies to packages/tom-server/src/identity-server/identity-server/index.ts : TwakeIdentityServer must add twakeDbCollections to extend the identity server database schema

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Support both PostgreSQL and SQLite Synapse configurations with driver-specific queries

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/userdb/*.ts : Select userdb backend via `user_db` config key: `sqlite`, `pg`, `ldap`, or empty string

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:27.917Z
Learning: Applies to packages/matrix-identity-server/src/index.ts : MatrixIdentityServer constructor takes (conf, confDesc?, db?) — conf must include server_name

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/sqlite.ts : In `db/src/sql/sqlite.ts`, implement SQLite adapter using `sqlite3` or `better-sqlite3`

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Avoid mutable module-level state without explicit ownership. If shared mutable state is required, wrap it in an explicit interface with named accessors.

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-03-27T16:21:28.793Z
Learning: Applies to **/*.{ts,tsx} : Do not introduce new `any` types in TypeScript — existing `any` warnings are tech debt, but new ones are blockers

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{ts,tsx} : The `any` type is forbidden without exception in TypeScript. Use a proper type, discriminated union, `unknown` with a guard, or a generic instead.

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Keep Synapse DB schema queries minimal and schema-version-aware to accommodate changes between Synapse versions

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/index.ts : In `db/src/index.ts`, export the main `Database` class, `Pg`, `SQLite`, and `createTables` function

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{ts,tsx} : Use `unknown` over `any` for data from external sources (HTTP responses, `JSON.parse`, event payloads, database rows). Write a type guard to validate the data.

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/**/*.ts : All SQL queries must use parameterized statements — never string-interpolate user input into SQL

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/sql.ts : In `db/src/sql/sql.ts`, implement base SQL utilities and shared query logic

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:46.846Z
Learning: Applies to packages/db/src/index.ts : Export `Database` class, adapter implementations (`Pg`, `SQLite`), `createTables` function, and column/condition types from `src/index.ts` in twake/db

Learnt from: pm-McFly
Repo: linagora/ToM-server PR: 355
File: packages/matrix-identity-server/src/db/index.ts:413-413
Timestamp: 2026-03-31T07:26:27.898Z
Learning: When reviewing TypeScript code in this repo, follow Biome’s `noDoubleEquals` rule: do not use loose equality (`== null` / `!= null`) as a shorthand. For nullish checks, use explicit strict comparisons instead (e.g., `value === null || value === undefined` or `value !== null && value !== undefined`).

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/matrix-identity-server/src/db/index.ts (1)

684-697: ⚠️ Potential issue | 🔴 Critical

Critical: setTimeout callback never executes.

Your dbMaintenance has a severe bug on lines 694 and 696:

this.cleanJob = setTimeout(() => _vacuum, delay * 1000);

This arrow function has an implicit return of _vacuum (the function reference) but never invokes it with (). When setTimeout fires, it will execute the arrow, which returns the function without calling it. Your vacuum job never runs.

Fix it:

-      this.cleanJob = setTimeout(() => _vacuum, delay * 1000);
+      this.cleanJob = setTimeout(() => { 
+        void _vacuum().catch((e) => this.logger.error('Vacuum failed', e)); 
+      }, delay * 1000);
     };
-    this.cleanJob = setTimeout(() => _vacuum, delay * 1000);
+    this.cleanJob = setTimeout(() => { 
+      void _vacuum().catch((e) => this.logger.error('Vacuum failed', e)); 
+    }, delay * 1000);

Or simpler (but loses async handling):

-      this.cleanJob = setTimeout(() => _vacuum, delay * 1000);
+      this.cleanJob = setTimeout(_vacuum, delay * 1000);
     };
-    this.cleanJob = setTimeout(() => _vacuum, delay * 1000);
+    this.cleanJob = setTimeout(_vacuum, delay * 1000);

The security scanner flagging setTimeout is a false positive—delay comes from config, not user input.

♻️ Duplicate comments (1)
packages/matrix-identity-server/src/db/index.ts (1)

182-182: ⚠️ Potential issue | 🟠 Major

Implicit any type on Module variable (still unfixed).

This was flagged in a previous review but remains unfixed. Type it properly:

-    let Module;
+    let Module: typeof Sqlite | typeof Pg;

As per coding guidelines: The any type is forbidden without exception in TypeScript.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c70978fc-87bc-4b49-b43d-7aae52e1517a

📥 Commits

Reviewing files that changed from the base of the PR and between 81cd5d9 and 1644f26.

📒 Files selected for processing (1)
  • packages/matrix-identity-server/src/db/index.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test / Test Affected Packages
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx,js,jsx,json,md}

📄 CodeRabbit inference engine (CLAUDE.md)

Use npm run format:check and npm run format:fix for code formatting checks

Files:

  • packages/matrix-identity-server/src/db/index.ts
packages/matrix-identity-server/src/db/**/*.{ts,js}

📄 CodeRabbit inference engine (CLAUDE.md)

MatrixIdentityServer initializes two databases: IdentityServerDb (identity-server tables) and UserDB (user directory)

Files:

  • packages/matrix-identity-server/src/db/index.ts
packages/matrix-identity-server/src/**/*.{ts,js}

📄 CodeRabbit inference engine (CLAUDE.md)

Routes are registered on this.api.get and this.api.post maps and mounted by the parent server

Files:

  • packages/matrix-identity-server/src/db/index.ts
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (CODING_STYLE.md)

**/*.{js,ts,jsx,tsx}: Use 2 spaces for indentation, not 4, tabs, or other amounts. Enforce with a formatter.
Opening braces must go on the same line. Never place opening braces on a new line.
Use trailing commas in multi-line structures (arrays, objects, function parameters) to minimize diff noise.
Semicolons are required on all statements. Do not rely on Automatic Semicolon Insertion (ASI).
Enforce a hard line length limit of 120 characters. Break overly complex expressions into named sub-expressions.
Use camelCase for variable and function names.
Use PascalCase for types, interfaces, classes, and enums.
Use SCREAMING_SNAKE_CASE only for module-level primitives that are truly constant and never change. Do not use for local bindings.
Boolean variables must read as a question using prefixes like is, has, can (e.g., isLoading, hasPermission, canRetry). Never use bare noun forms.
Do not abbreviate variable or function names except for: i, j in tight loops; e for event parameters; err for errors; ctx for context; req/res in HTTP handlers.
Each function must do exactly one job. Do not write functions that combine multiple concerns (e.g., avoid fetchAndTransformUser). Extract compound operations into separate functions.
Functions must have a maximum of 5 parameters. For more than 5 parameters, group related data into a typed options object.
Keep functions short, with a reasonable ceiling of 25–40 lines. Functions should fit on one screen without scrolling.
Every function must return a meaningful value. void return types are forbidden. Use ActionResult for functions with no natural data return.
Recursion must be tail-call or converted to an iterative loop. Non-tail-recursive functions are forbidden in production code because JavaScript engines do not reliably optimize tail calls.
Maximum nesting depth is 2 levels (level 0 is function body, level 1 is a block inside it, level 2 is a block inside that). Extract sub-problems into named functi...

Files:

  • packages/matrix-identity-server/src/db/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CODING_STYLE.md)

**/*.{ts,tsx}: Return types must be explicitly annotated on all non-trivial functions in TypeScript. Inference alone is not a contract.
The any type is forbidden without exception in TypeScript. Use a proper type, discriminated union, unknown with a guard, or a generic instead.
Double casts via as unknown as T are forbidden. If the type model is inconsistent, fix the model instead.
Use unknown over any for data from external sources (HTTP responses, JSON.parse, event payloads, database rows). Write a type guard to validate the data.
Prefer type for unions and intersections; prefer interface for object shapes. Keep intent readable through consistent use.
Avoid TypeScript enum. Use string union types for fully internal values. For values from external sources, provide a validation helper that narrows conversion from raw strings.
In TypeScript, caught values have type unknown, not Error. Use instanceof Error checks before accessing Error-specific properties.
Do not use @ts-ignore or @ts-expect-error without an explanatory comment stating the reason and removal condition.

Do not introduce new any types in TypeScript — existing any warnings are tech debt, but new ones are blockers

Files:

  • packages/matrix-identity-server/src/db/index.ts
🧠 Learnings (30)
📓 Common learnings
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/**/*.ts : Use `node-cron` schedule syntax for new jobs in the cron directory
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/**/*.ts : Cron intervals are configured via config keys (e.g., `pepper_cron`, `userdb_cron`)
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/cron/*.ts : Configure cron job intervals via config keys; cron jobs run on server startup
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/matrix-identity-server/src/db/**/*.{ts,js} : `MatrixIdentityServer` initializes two databases: `IdentityServerDb` (identity-server tables) and `UserDB` (user directory)
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Keep Synapse DB schema queries minimal and schema-version-aware to accommodate changes between Synapse versions
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/user-info-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:38.144Z
Learning: Applies to packages/tom-server/src/user-info-api/user-info-api/**/*.ts : Store visibility settings in the identity server DB (not MatrixDB)
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Use matrixDb queries in cron/changePepper.ts to filter active Matrix users when updating hashes
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:51.582Z
Learning: Applies to packages/tom-server/src/identity-server/identity-server/{index.test,with-cache.test}.ts : Write integration tests for TwakeIdentityServer in index.test.ts and cache-enabled lookup behavior in with-cache.test.ts
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/metrics-api/AGENTS.md:0-0
Timestamp: 2026-03-17T11:24:13.473Z
Learning: Applies to packages/tom-server/src/metrics-api/**/metrics-api/services/**/*.ts : Services in metrics-api must query the Matrix (Synapse) database directly, not the identity server DB
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/cron/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:55.851Z
Learning: Applies to packages/matrix-identity-server/src/cron/cron/changePepper.ts : `changePepper.ts` is a critical job that invalidates all existing hashes and rebuilds them — run carefully
📚 Learning: 2026-03-17T11:22:24.131Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Keep Synapse DB schema queries minimal and schema-version-aware to accommodate changes between Synapse versions

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:22:24.131Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Support both PostgreSQL and SQLite Synapse configurations with driver-specific queries

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-23T09:08:39.061Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/matrix-identity-server/src/db/**/*.{ts,js} : `MatrixIdentityServer` initializes two databases: `IdentityServerDb` (identity-server tables) and `UserDB` (user directory)

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:22:06.022Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/sql/{pg,sqlite}.ts : When adding a new table, define schema in `db/index.ts`, and add SQL implementations in both `db/sql/pg.ts` (PostgreSQL) and `db/sql/sqlite.ts` (SQLite)

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:22:24.131Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Reference configuration keys: matrix_database_engine (pg/sqlite), matrix_database_host, matrix_database_name for database connections

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:21:40.136Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/userdb/*.ts : Select userdb backend via `user_db` config key: `sqlite`, `pg`, `ldap`, or empty string

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:22:06.022Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/**/*.ts : All SQL queries must use parameterized statements — never string-interpolate user input into SQL

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:22:06.022Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/index.ts : Add new identity server tables to the `Collections` enum in `db/index.ts`

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:21:27.917Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:27.917Z
Learning: Applies to packages/matrix-identity-server/src/index.ts : The db property exposes the identity server's database for subclass use

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:21:40.136Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/db/index.ts : Add new database table names to the `Collections` enum in `db/index.ts`

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-27T16:21:10.935Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{ts,tsx} : The `any` type is forbidden without exception in TypeScript. Use a proper type, discriminated union, `unknown` with a guard, or a generic instead.

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-27T16:21:10.935Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Avoid mutable module-level state without explicit ownership. If shared mutable state is required, wrap it in an explicit interface with named accessors.

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:56.983Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/sqlite.ts : In `db/src/sql/sqlite.ts`, implement SQLite adapter using `sqlite3` or `better-sqlite3`

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-27T16:21:10.935Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{ts,tsx} : Use `unknown` over `any` for data from external sources (HTTP responses, `JSON.parse`, event payloads, database rows). Write a type guard to validate the data.

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-27T16:21:28.793Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-03-27T16:21:28.793Z
Learning: Applies to **/*.{ts,tsx} : Do not introduce new `any` types in TypeScript — existing `any` warnings are tech debt, but new ones are blockers

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:56.983Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/index.ts : In `db/src/index.ts`, export the main `Database` class, `Pg`, `SQLite`, and `createTables` function

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:56.983Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/sql.ts : In `db/src/sql/sql.ts`, implement base SQL utilities and shared query logic

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:56.983Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/pg.ts : In `db/src/sql/pg.ts`, implement PostgreSQL adapter using `pg` driver with connection pooling and parameterized queries

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-27T16:21:10.935Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Use strict equality (`===`) instead of loose equality (`==`). Do not rely on JavaScript's implicit type coercion.

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:23:51.582Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/src/identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:51.582Z
Learning: Applies to packages/tom-server/src/identity-server/identity-server/index.ts : TwakeIdentityServer must add twakeDbCollections to extend the identity server database schema

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:21:27.917Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:27.917Z
Learning: Applies to packages/matrix-identity-server/src/index.ts : this.ready is a Promise that resolves when async initialization (key gen, DB setup) completes

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:56.983Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/database.ts : In `db/src/database.ts`, implement the `Database` base class for connection management and query interface

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:56.983Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/_createTables.ts : In `db/src/sql/_createTables.ts`, implement `createTables()` function to create tables from schema definitions if they don't exist

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:46.846Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:46.846Z
Learning: Applies to packages/db/src/index.ts : Export `Database` class, adapter implementations (`Pg`, `SQLite`), `createTables` function, and column/condition types from `src/index.ts` in twake/db

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:22:24.131Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Implement query methods getAll(), get(), and match() in the MatrixDB class for querying Synapse tables

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:20:56.983Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/types.ts : In `db/src/types.ts`, define column definitions, condition operators, and table schema types

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:21:45.978Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/account/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:45.978Z
Learning: Applies to packages/matrix-identity-server/src/account/account/{register,logout}.ts : Access tokens are stored in the `accessTokens` DB collection

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:23:13.313Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/tom-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:23:13.313Z
Learning: Applies to packages/tom-server/**/*.{ts,tsx} : Await the `this.ready` Promise before handling requests to ensure DB, key generation, and all services are initialized

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
📚 Learning: 2026-03-17T11:21:45.978Z
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/account/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:45.978Z
Learning: Applies to packages/matrix-identity-server/src/account/account/logout.ts : POST `/_matrix/identity/v2/account/logout` endpoint deletes the current access token from DB

Applied to files:

  • packages/matrix-identity-server/src/db/index.ts
🪛 Biome (2.4.9)
packages/matrix-identity-server/src/db/index.ts

[error] 109-116: Function has 6 parameters, but only 5 are allowed.

(lint/complexity/useMaxParams)


[error] 117-125: Function has 7 parameters, but only 5 are allowed.

(lint/complexity/useMaxParams)


[error] 144-144: Unexpected any. Specify a different type.

(lint/suspicious/noExplicitAny)


[error] 182-182: This variable implicitly has the any type.

(lint/suspicious/noImplicitAnyLet)

🔇 Additional comments (1)
packages/matrix-identity-server/src/db/index.ts (1)

1-26: Clean import organization and type definitions.

The switch to double quotes, semicolons, and import type for the logger is solid. The Collections union is properly formatted.

Comment on lines 102 to +125
type GetMinMax<T> = (
table: T,
targetField: string,
fields: string[],
filterFields: Record<string, string | number | Array<string | number>>,
order?: string
) => Promise<DbGetResult>
order?: string,
) => Promise<DbGetResult>;
type GetMinMax2<T> = (
table: T,
targetField: string,
fields: string[],
filterFields1: Record<string, string | number | Array<string | number>>,
filterFields2: Record<string, string | number | Array<string | number>>,
order?: string
) => Promise<DbGetResult>
order?: string,
) => Promise<DbGetResult>;
type GetMinMaxJoin2<T> = (
tables: T[],
targetField: string,
fields: string[],
filterFields1: Record<string, string | number | Array<string | number>>,
filterFields2: Record<string, string | number | Array<string | number>>,
joinFields: Record<string, string>,
order?: string
) => Promise<DbGetResult>
type GetCount<T> = (
table: T,
field: string,
value?: string | number | string[]
) => Promise<number>
type GetAll<T> = (
table: T,
fields: string[],
order?: string
) => Promise<DbGetResult>
type Match<T> = (
table: T,
fields: string[],
searchFields: string[],
value: string | number
) => Promise<DbGetResult>
type DeleteEqual<T> = (
table: T,
field: string,
value: string | number
) => Promise<void>
order?: string,
) => Promise<DbGetResult>;
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Mar 31, 2026

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Type signatures exceed parameter limit.

Your type aliases here pack 6-7 parameters, violating the 5-parameter ceiling. Consolidate related filter arguments into a typed options object:

type QueryOptions = {
  targetField?: string;
  fields: string[];
  filterFields1: Record<string, string | number | Array<string | number>>;
  filterFields2?: Record<string, string | number | Array<string | number>>;
  joinFields?: Record<string, string>;
  order?: string;
};

type GetMinMaxJoin2<T> = (
  tables: T[],
  options: QueryOptions,
) => Promise<DbGetResult>;

This tech debt predates your PR, but worth addressing when refactoring the DB layer.

As per coding guidelines: Functions must have a maximum of 5 parameters. For more than 5 parameters, group related data into a typed options object.

🧰 Tools
🪛 Biome (2.4.9)

[error] 109-116: Function has 6 parameters, but only 5 are allowed.

(lint/complexity/useMaxParams)


[error] 117-125: Function has 7 parameters, but only 5 are allowed.

(lint/complexity/useMaxParams)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@coderabbitai you got a valid point but this is outside of this PR scope

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@pm-McFly, understood — this is pre-existing tech debt unrelated to the quota removal. Would you like me to open a follow-up GitHub issue to track the GetMinMaxJoin2/GetMinMax2 parameter consolidation so it doesn't get lost?


🧠 Learnings used
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Support both PostgreSQL and SQLite Synapse configurations with driver-specific queries

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Implement query methods getAll(), get(), and match() in the MatrixDB class for querying Synapse tables

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/sql/{pg,sqlite}.ts : When adding a new table, define schema in `db/index.ts`, and add SQL implementations in both `db/sql/pg.ts` (PostgreSQL) and `db/sql/sqlite.ts` (SQLite)

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Reference configuration keys: matrix_database_engine (pg/sqlite), matrix_database_host, matrix_database_name for database connections

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/index.ts : Add new identity server tables to the `Collections` enum in `db/index.ts`

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/matrix-identity-server/src/db/**/*.{ts,js} : `MatrixIdentityServer` initializes two databases: `IdentityServerDb` (identity-server tables) and `UserDB` (user directory)

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Keep Synapse DB schema queries minimal and schema-version-aware to accommodate changes between Synapse versions

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/db/index.ts : Add new database table names to the `Collections` enum in `db/index.ts`

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/userdb/*.ts : Select userdb backend via `user_db` config key: `sqlite`, `pg`, `ldap`, or empty string

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/types.ts : In `db/src/types.ts`, define column definitions, condition operators, and table schema types

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Functions must have a maximum of 5 parameters. For more than 5 parameters, group related data into a typed options object.

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/**/*.ts : All SQL queries must use parameterized statements — never string-interpolate user input into SQL

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/index.ts : In `db/src/index.ts`, export the main `Database` class, `Pg`, `SQLite`, and `createTables` function

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/sql.ts : In `db/src/sql/sql.ts`, implement base SQL utilities and shared query logic

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:46.846Z
Learning: Applies to packages/db/src/index.ts : Export `Database` class, adapter implementations (`Pg`, `SQLite`), `createTables` function, and column/condition types from `src/index.ts` in twake/db

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/sqlite.ts : In `db/src/sql/sqlite.ts`, implement SQLite adapter using `sqlite3` or `better-sqlite3`

Learnt from: pm-McFly
Repo: linagora/ToM-server PR: 355
File: packages/matrix-identity-server/src/db/index.ts:413-413
Timestamp: 2026-03-31T07:26:27.898Z
Learning: When reviewing TypeScript code in this repo, follow Biome’s `noDoubleEquals` rule: do not use loose equality (`== null` / `!= null`) as a shorthand. For nullish checks, use explicit strict comparisons instead (e.g., `value === null || value === undefined` or `value !== null && value !== undefined`).

deleteWhere: DeleteWhere<T>
close: () => void
ready: Promise<void>;
createDatabases: (conf: Config, ...args: any) => Promise<void>;
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Mar 31, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Forbidden any type in interface signature.

Your createDatabases method uses ...args: any, which is absolutely forbidden. Either define a proper typed tuple for variadic args, or remove the rest parameter if it's not actually used:

-  createDatabases: (conf: Config, ...args: any) => Promise<void>;
+  createDatabases: (conf: Config) => Promise<void>;

If you genuinely need variadic args, type them properly:

createDatabases: (conf: Config, ...args: Array<Record<string, unknown>>) => Promise<void>;

As per coding guidelines: The any type is forbidden without exception in TypeScript. Use a proper type, discriminated union, unknown with a guard, or a generic instead.

🧰 Tools
🪛 Biome (2.4.9)

[error] 144-144: Unexpected any. Specify a different type.

(lint/suspicious/noExplicitAny)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@coderabbitai you got a valid point but this is outside of this PR scope

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@pm-McFly Fair enough — that any predates this PR and cleaning it up is a separate concern. Would you like me to open a follow-up issue to track removing ...args: any from IdDbBackend.createDatabases in packages/matrix-identity-server/src/db/index.ts?


🧠 Learnings used
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Reference configuration keys: matrix_database_engine (pg/sqlite), matrix_database_host, matrix_database_name for database connections

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Support both PostgreSQL and SQLite Synapse configurations with driver-specific queries

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/userdb/*.ts : Select userdb backend via `user_db` config key: `sqlite`, `pg`, `ldap`, or empty string

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/sql/{pg,sqlite}.ts : When adding a new table, define schema in `db/index.ts`, and add SQL implementations in both `db/sql/pg.ts` (PostgreSQL) and `db/sql/sqlite.ts` (SQLite)

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/matrix-identity-server/src/db/**/*.{ts,js} : `MatrixIdentityServer` initializes two databases: `IdentityServerDb` (identity-server tables) and `UserDB` (user directory)

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Implement query methods getAll(), get(), and match() in the MatrixDB class for querying Synapse tables

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/userdb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:38.835Z
Learning: Applies to packages/matrix-identity-server/src/userdb/userdb/**/*.ts : All backends in the userdb module must implement the same interface with methods `get()`, `getAll()`, and `match()` for querying user information

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:27.917Z
Learning: Applies to packages/matrix-identity-server/src/index.ts : The db property exposes the identity server's database for subclass use

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/index.ts : Add new identity server tables to the `Collections` enum in `db/index.ts`

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/db/index.ts : Add new database table names to the `Collections` enum in `db/index.ts`

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{ts,tsx} : The `any` type is forbidden without exception in TypeScript. Use a proper type, discriminated union, `unknown` with a guard, or a generic instead.

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-03-27T16:21:28.793Z
Learning: Applies to **/*.{ts,tsx} : Do not introduce new `any` types in TypeScript — existing `any` warnings are tech debt, but new ones are blockers

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/**/*.ts : All SQL queries must use parameterized statements — never string-interpolate user input into SQL

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{ts,tsx} : Use `unknown` over `any` for data from external sources (HTTP responses, `JSON.parse`, event payloads, database rows). Write a type guard to validate the data.

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Keep Synapse DB schema queries minimal and schema-version-aware to accommodate changes between Synapse versions

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:27.917Z
Learning: Applies to packages/matrix-identity-server/src/index.ts : MatrixIdentityServer constructor takes (conf, confDesc?, db?) — conf must include server_name

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/index.ts : In `db/src/index.ts`, export the main `Database` class, `Pg`, `SQLite`, and `createTables` function

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/sql.ts : In `db/src/sql/sql.ts`, implement base SQL utilities and shared query logic

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:46.846Z
Learning: Applies to packages/db/src/index.ts : Export `Database` class, adapter implementations (`Pg`, `SQLite`), `createTables` function, and column/condition types from `src/index.ts` in twake/db

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/sqlite.ts : In `db/src/sql/sqlite.ts`, implement SQLite adapter using `sqlite3` or `better-sqlite3`

Learnt from: pm-McFly
Repo: linagora/ToM-server PR: 355
File: packages/matrix-identity-server/src/db/index.ts:413-413
Timestamp: 2026-03-31T07:26:27.898Z
Learning: When reviewing TypeScript code in this repo, follow Biome’s `noDoubleEquals` rule: do not use loose equality (`== null` / `!= null`) as a shorthand. For nullish checks, use explicit strict comparisons instead (e.g., `value === null || value === undefined` or `value !== null && value !== undefined`).

deleteEqualAnd: DeleteEqualAnd<T>;
deleteLowerThan: DeleteLowerThan<T>;
deleteWhere: DeleteWhere<T>;
close: () => void;
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Mar 31, 2026

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

void return type violates coding standards.

The close() method returns void, which is explicitly forbidden by the style guide. You should return a meaningful value or an ActionResult to signal completion status.

That said, resource cleanup methods like close() are one of the few legitimate uses of void in practice. If you're willing to bend the rule here for pragmatism (I would), document the exception. Otherwise, return a success indicator:

close: () => { success: boolean };

As per coding guidelines: Every function must return a meaningful value. void return types are forbidden. Use ActionResult for functions with no natural data return.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@coderabbitai you got a valid point but this is outside of this PR scope

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@pm-McFly Fair enough — this PR is about quota removal, not style enforcement. Would you like me to open a follow-up issue to track fixing the void return type on close() (and any other occurrences) so it doesn't get lost?


🧠 Learnings used
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Reference configuration keys: matrix_database_engine (pg/sqlite), matrix_database_host, matrix_database_name for database connections

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Support both PostgreSQL and SQLite Synapse configurations with driver-specific queries

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/userdb/*.ts : Select userdb backend via `user_db` config key: `sqlite`, `pg`, `ldap`, or empty string

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/sql/{pg,sqlite}.ts : When adding a new table, define schema in `db/index.ts`, and add SQL implementations in both `db/sql/pg.ts` (PostgreSQL) and `db/sql/sqlite.ts` (SQLite)

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/matrix-identity-server/src/db/**/*.{ts,js} : `MatrixIdentityServer` initializes two databases: `IdentityServerDb` (identity-server tables) and `UserDB` (user directory)

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Implement query methods getAll(), get(), and match() in the MatrixDB class for querying Synapse tables

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/userdb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:38.835Z
Learning: Applies to packages/matrix-identity-server/src/userdb/userdb/**/*.ts : All backends in the userdb module must implement the same interface with methods `get()`, `getAll()`, and `match()` for querying user information

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:27.917Z
Learning: Applies to packages/matrix-identity-server/src/index.ts : The db property exposes the identity server's database for subclass use

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/index.ts : Add new identity server tables to the `Collections` enum in `db/index.ts`

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Keep Synapse DB schema queries minimal and schema-version-aware to accommodate changes between Synapse versions

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Every function must return a meaningful value. `void` return types are forbidden. Use `ActionResult` for functions with no natural data return.

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/amqp-connector/AGENTS.md:0-0
Timestamp: 2026-03-17T11:19:45.697Z
Learning: Applies to packages/amqp-connector/src/**/*.{ts,tsx} : Use `close()` method for cleanup, which is safe to call at any connection state including during reconnection

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/**/*.ts : All SQL queries must use parameterized statements — never string-interpolate user input into SQL

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/index.ts : In `db/src/index.ts`, export the main `Database` class, `Pg`, `SQLite`, and `createTables` function

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/sql.ts : In `db/src/sql/sql.ts`, implement base SQL utilities and shared query logic

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:46.846Z
Learning: Applies to packages/db/src/index.ts : Export `Database` class, adapter implementations (`Pg`, `SQLite`), `createTables` function, and column/condition types from `src/index.ts` in twake/db

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/sqlite.ts : In `db/src/sql/sqlite.ts`, implement SQLite adapter using `sqlite3` or `better-sqlite3`

Learnt from: pm-McFly
Repo: linagora/ToM-server PR: 355
File: packages/matrix-identity-server/src/db/index.ts:413-413
Timestamp: 2026-03-31T07:26:27.898Z
Learning: When reviewing TypeScript code in this repo, follow Biome’s `noDoubleEquals` rule: do not use loose equality (`== null` / `!= null`) as a shorthand. For nullish checks, use explicit strict comparisons instead (e.g., `value === null || value === undefined` or `value !== null && value !== undefined`).

/* istanbul ignore if */
if (this.db == null) {
throw new Error('Wait for database to be ready')
if (this.db === null || this.db === undefined) {
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Mar 31, 2026

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Overly verbose null check.

You're checking this.db === null || this.db === undefined in dozens of places. Use the != null pattern instead—it checks both with one comparison:

-    if (this.db === null || this.db === undefined) {
+    if (this.db != null) {
+      // happy path
+    } else {
       throw new Error("Wait for database to be ready");
     }

Or with a guard:

-    if (this.db === null || this.db === undefined) {
+    if (this.db == null) {
       throw new Error("Wait for database to be ready");
     }

TypeScript's != null intentionally uses loose equality to catch both null and undefined. This is one of the few legitimate uses of != over !==.

Apply this pattern to lines 413, 449, 479, 494, 519, 543, 565, 586, 616, 666.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@coderabbitai nope! this is not compliant with the coding style and standards enforced with biome

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@pm-McFly, you're absolutely right. Biome's noDoubleEquals rule treats == and != as errors across the board — it doesn't carve out an exception for the == null pattern. My suggestion was wrong; the current === null || === undefined form is the correct and compliant approach for this codebase. Apologies for the noise.


✏️ Learnings added
Learnt from: pm-McFly
Repo: linagora/ToM-server PR: 355
File: packages/matrix-identity-server/src/db/index.ts:413-413
Timestamp: 2026-03-31T07:26:27.898Z
Learning: In linagora/ToM-server, Biome's `noDoubleEquals` rule is enforced, which prohibits `== null` and `!= null` patterns. The correct null/undefined check pattern is `=== null || === undefined` (or `!== null && !== undefined`). Do not suggest using loose equality (`== null`) as a shorthand even for null checks.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/index.ts : Add new identity server tables to the `Collections` enum in `db/index.ts`

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Implement query methods getAll(), get(), and match() in the MatrixDB class for querying Synapse tables

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:27.917Z
Learning: Applies to packages/matrix-identity-server/src/index.ts : The db property exposes the identity server's database for subclass use

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/db/index.ts : Add new database table names to the `Collections` enum in `db/index.ts`

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-23T09:08:39.061Z
Learning: Applies to packages/matrix-identity-server/src/db/**/*.{ts,js} : `MatrixIdentityServer` initializes two databases: `IdentityServerDb` (identity-server tables) and `UserDB` (user directory)

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Support both PostgreSQL and SQLite Synapse configurations with driver-specific queries

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/index.ts : Reference configuration keys: matrix_database_engine (pg/sqlite), matrix_database_host, matrix_database_name for database connections

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/account/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:45.978Z
Learning: Applies to packages/matrix-identity-server/src/account/account/{register,logout}.ts : Access tokens are stored in the `accessTokens` DB collection

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/userdb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:38.835Z
Learning: Applies to packages/matrix-identity-server/src/userdb/userdb/**/*.ts : All backends in the userdb module must implement the same interface with methods `get()`, `getAll()`, and `match()` for querying user information

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/sql/{pg,sqlite}.ts : When adding a new table, define schema in `db/index.ts`, and add SQL implementations in both `db/sql/pg.ts` (PostgreSQL) and `db/sql/sqlite.ts` (SQLite)

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: CODING_STYLE.md:0-0
Timestamp: 2026-03-27T16:21:10.935Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Use strict equality (`===`) instead of loose equality (`==`). Do not rely on JavaScript's implicit type coercion.

Learnt from: pm-McFly
Repo: linagora/ToM-server PR: 341
File: biome.json:58-58
Timestamp: 2026-03-18T21:36:12.246Z
Learning: In linagora/ToM-server, the `noConsole: "error"` rule in `biome.json` is intentionally strict. The linting pipeline is expected to fail temporarily while existing `console.*` calls are progressively replaced with `twake/logger` (TwakeLogger). This is a deliberate enforcement strategy, not an oversight.

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/matrixDb/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:24.131Z
Learning: Applies to packages/matrix-identity-server/src/matrixDb/matrixDb/sql/**/*.ts : Keep Synapse DB schema queries minimal and schema-version-aware to accommodate changes between Synapse versions

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:22:06.022Z
Learning: Applies to packages/matrix-identity-server/src/db/db/**/*.ts : All SQL queries must use parameterized statements — never string-interpolate user input into SQL

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/index.ts : In `db/src/index.ts`, export the main `Database` class, `Pg`, `SQLite`, and `createTables` function

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/sql.ts : In `db/src/sql/sql.ts`, implement base SQL utilities and shared query logic

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:46.846Z
Learning: Applies to packages/db/src/index.ts : Export `Database` class, adapter implementations (`Pg`, `SQLite`), `createTables` function, and column/condition types from `src/index.ts` in twake/db

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/matrix-identity-server/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:21:40.136Z
Learning: Applies to packages/matrix-identity-server/src/src/userdb/*.ts : Select userdb backend via `user_db` config key: `sqlite`, `pg`, `ldap`, or empty string

Learnt from: CR
Repo: linagora/ToM-server PR: 0
File: packages/db/src/AGENTS.md:0-0
Timestamp: 2026-03-17T11:20:56.983Z
Learning: Applies to packages/db/src/db/src/sql/sqlite.ts : In `db/src/sql/sqlite.ts`, implement SQLite adapter using `sqlite3` or `better-sqlite3`

Signed-off-by: Pierre 'McFly' Marty <pmarty@linagora.com>
@pm-McFly pm-McFly added chore Modification that does not relate to a bug fix, a new feature or a documentation update package::identity-server javascript Pull requests that update javascript code labels Mar 31, 2026
@pm-McFly pm-McFly merged commit 9011b67 into dev Mar 31, 2026
9 of 11 checks passed
@pm-McFly pm-McFly deleted the chore/remove-quota-references branch March 31, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Modification that does not relate to a bug fix, a new feature or a documentation update javascript Pull requests that update javascript code package::identity-server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants