Skip to content

OUT-4044: row state transitions + channel cascade soft-delete - #130

Open
SandipBajracharya wants to merge 1 commit into
OUT-4043from
OUT-4044
Open

OUT-4044: row state transitions + channel cascade soft-delete#130
SandipBajracharya wants to merge 1 commit into
OUT-4043from
OUT-4044

Conversation

@SandipBajracharya

Copy link
Copy Markdown
Collaborator

What

Direct-DB integration tests for MapFilesService against Testcontainers Postgres — the row state-transition helpers, the channel cascade soft-delete transaction, and the guard asymmetry between the two read paths (OUT-4044).

test/flows/row-state-transitions.integration.test.ts (17 tests):

markAttempt

  • increments the attempt count + clears the last error when action & target are unchanged
  • resets to 1 when the target changes, and when the action changes (both AND branches of the CASE)
  • throws when the row is missing; throws when the row belongs to another portal (portal guard)

markDeleted

  • soft-deletes and clears every pending field
  • throws when the row is missing; throws + leaves the row live under the portal guard

markUpdated

  • applies the payload + clears pending fields, without tombstoning (deletedAt stays null)
  • throws when the row is missing; throws + leaves the row unchanged under the portal guard

markFailure

  • records a truncated (500-char cap) error and stamps pendingActionLastAttemptAt
  • does not throw when the row is missing — the deliberate contrast with the guarded mark* helpers

deleteChannelMapsByIds

  • cascade soft-deletes the channel (deletedAt + status=false) and its file rows in one transaction, leaving a sibling channel and its rows untouched
  • no-op on an empty id list

getAllFileMaps vs getSingleFileMap

  • getAllFileMaps hides a soft-deleted row / another portal's row; getSingleFileMap returns both (no soft-delete or portal guard) — same row id queried through both paths

Why

Part of the DB-integration suite (parent OUT-4042). These are real-Postgres behaviors — the CASE attempt logic, the portal filter, the transactional cascade, and the guard asymmetry — that mocks can't reproduce, so they run against a container DB.

Verification

  • pnpm test:integration test/flows/row-state-transitions.integration.test.ts → 17/17 pass
  • pnpm lint clean · pnpm typecheck clean

Notes

  • Base is OUT-4043 (stacked: OUT-4041 → OUT-4043 → OUT-4044).
  • Reviewed by fullstack-code-reviewer — verdict Looks Good, no false positives; its two actionable suggestions (complete the markAttempt CASE truth table, add markDeleted/markUpdated portal guards) are applied.
  • Finding surfaced during review: getSingleFileMap currently has no production call sites (dead code). Left in place for now; flagged for a possible follow-up cleanup.

🤖 Generated with Claude Code

…e tests

Direct-DB integration tests for MapFilesService against Testcontainers
Postgres: markAttempt attempt increment-vs-reset (both AND branches) and the
portal guard, markDeleted/markUpdated clear-fields + portal guards, markFailure
truncation and its missing-row no-throw contrast, the deleteChannelMapsByIds
cascade soft-delete transaction, and the soft-delete/portal guard difference
between getAllFileMaps and getSingleFileMap.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Aug 14, 2026

Copy link
Copy Markdown

OUT-4044

@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dropbox-integration Ready Ready Preview Aug 14, 2026 10:45am

Request Review

@SandipBajracharya SandipBajracharya changed the title test(OUT-4044): row state transitions + channel cascade soft-delete OUT-4044: row state transitions + channel cascade soft-delete Aug 14, 2026
@greptile-apps

greptile-apps Bot commented Aug 14, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds direct-Postgres integration coverage for MapFilesService state transitions, cascade soft deletion, and read-path guard behavior.

  • Exercises attempt-count reset and increment behavior, pending-state cleanup, failure recording, and missing-row handling.
  • Verifies transactional channel/file soft deletion and empty-ID behavior.
  • Documents the differing soft-delete and portal filtering behavior of the single-row and multi-row reads.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains within the follow-up review scope.

Important Files Changed

Filename Overview
test/flows/row-state-transitions.integration.test.ts Adds focused integration tests for row transitions, cascade deletion, portal guards, and read-path filtering differences without changing production behavior.

Reviews (2): Last reviewed commit: "test(OUT-4044): add row state-transition..." | Re-trigger Greptile

Comment thread test/flows/row-state-transitions.integration.test.ts
@SandipBajracharya

Copy link
Copy Markdown
Collaborator Author

@greptileai review PR again

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