Skip to content

chore(models): remove dead Session and DiscordMessageBuffer (TASK-506) - #2680

Merged
lilyshen0722 merged 1 commit into
mainfrom
polish/task-506-dead-models
Oct 25, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
polish/task-506-dead-models

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

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/main at 136709aa02d5b1106e63925c489ca06a6e897de6 (2,731 tracked files).

  • git grep -l -F DiscordMessageBuffer origin/main -- . returns only backend/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 only backend/__tests__/unit/models/Session.contextSettings.test.js. No production importer exists.
  • Exported Session types ITranscriptEntry, ITokenUsage, and ISessionModel appear only in Session.ts. SessionState additionally appears in the historical ADR-007, not executable code.
  • No 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.
  • Scanned all backend and root scripts for model imports, named Mongoose registration/lookup, and collection access. No route, controller, service or script references either model. Session's default collection is sessions; its only quoted occurrence is path.join(agentStateDir, 'sessions') in agentProvisionerService.ts, a runtime filesystem directory, not a Mongo read. Discord's explicit collection is discord_message_buffer.
  • Deleted the only matching test and its inline fixture. No DiscordMessageBuffer test or fixture exists.

Verification

  • npm run build --prefix backend reaches TypeScript but is blocked by the reused local dependency tree missing playwright-core: TS2307 at unchanged services/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 --check passes.
  • Deletion-only change; no new behavior or test added.

SRE follow-up

Leave Mongo sessions and discord_message_buffer collections 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.

Co-authored-by: Polish <[email protected]>
Agent-Model: codex/gpt-6.1-sol/medium
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 136709a and 0024fc4.

Files selected for processing: 3
  • backend/__tests__/unit/models/Session.contextSettings.test.js
  • backend/models/DiscordMessageBuffer.ts
  • backend/models/Session.ts
Files with no reviewable changes: 3
  • backend/tests/unit/models/Session.contextSettings.test.js
  • backend/models/DiscordMessageBuffer.ts
  • backend/models/Session.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Walkthrough

The pull request deletes the Session and DiscordMessageBuffer models. It also deletes a unit test that checked for the absence of two Session properties.

Changes: Session model removal

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: Low

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: Passed 4
Check name Status Explanation
Description check Passed The description clearly explains the deletion of the unused Session and DiscordMessageBuffer models, the related test, verification results, and collection-retention constraints.
Title check Passed The title clearly and concisely identifies the main change: removing the unused Session and DiscordMessageBuffer models.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
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 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

PASS at 0024fc4 for the deletion. Three files, 246 lines removed, nothing added.

Checked:

  • No reference to models/Session, models/DiscordMessageBuffer, mongoose.model('Session'), or ref: 'Session' remains under backend, cli, scripts or k8s at this head. The only hits are the two deleted files and their test.
  • User.test.js runs 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 --noEmit reports 50 errors, all in test-discord-*.ts and cleanup-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

@lilyshen0722
lilyshen0722 added this pull request to the merge queue Oct 25, 2026
Merged via the queue into main with commit 4eed277 Oct 25, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant