Skip to content

fix(apps): close review gaps in the legacy feature handoff journal - #561

Merged
RentnerKev merged 1 commit into
mainfrom
rentner/fix/legacy-handoff-review
Nov 24, 2026
Merged

RentnerKev merged 1 commit into
mainfrom
rentner/fix/legacy-handoff-review

Conversation

@RentnerKev

Copy link
Copy Markdown
Member

Summary

This PR fixes the eleven CodeRabbit findings that were still open when #560 merged. None of them was reachable yet, because no legacy feature source is registered. Each one would have mattered once the Monitoring extraction plugs in its source.

Lock protocol

  • lockLegacyFeatureDomain, which backs begin, commit and abort, now refuses two kinds of transaction:
    • anything other than read committed. A repeatable read snapshot taken before the lock wait could export a stale state and then retire newer platform data.
    • a transaction that already holds a platform writer's shared lock for the domain. PostgreSQL would grant its own exclusive request immediately, which would defeat the fence.
  • inspectLegacyFeaturesInTransaction takes shared locks on all domains before it reads the owners and runs the source inspections. A handoff therefore cannot commit between the two reads, and the preview never pairs owner: platform with retired state.

Export

  • Parts are serialized in a guarded step. The serialized text is validated against the wire contract too, so an inherited or non-enumerable toJSON cannot store values outside the contract. A throwing getter or hook counts as an invalid part and is recorded as the failure, even if the source swallows it.
  • Rejected emits carry a handler, so fire-and-forget sources do not leave unhandled rejections, and begin still rejects.
  • begin settles every accepted part in a finally block before it returns or rethrows. No insert outlives the call on an abandoned transaction.

Docs

  • retire documents that it can run again after a rolled-back commit, and that it must make its changes through the supplied transaction.

Tests

  • The DB tests refuse to run when another handoff holds the test domain. Cleanup removes only the handoff and installations the test created.
  • The plaintext check covers every stored ciphertext.
  • The fence test waits until the handoff is queued in pg_locks and asserts that the export has not started. It also proves that the preview waits for the handoff. finally settles all transactions before it restores the key and removes fixtures.
  • New cases cover:
    • the read committed and same-transaction guards;
    • unsafe and vanishing toJSON;
    • throwing getters;
    • fire-and-forget invalid parts;
    • settlement of accepted parts when the export fails.

Related issue

Refs #457. Follow-up to #560.

Type of change

  • Bug fix
  • New feature
  • Refactoring
  • Documentation
  • CI / tooling
  • Dependency update
  • Other

Testing

  • web/src/tests/server/LegacyHandoff/ against PostgreSQL 18: 6 pass. The handoff modules keep 100% line coverage.
  • Cross-check: run against the previous web/src/server/LegacyHandoff code, the new tests fail in exactly the reported gaps:
    • invalid exports are accepted;
    • the preview is not held back;
    • the lock guard is missing.
  • Typecheck and oxlint (default and type-aware) pass.

Checklist

  • I tested the relevant functionality.
  • Existing tests pass.
  • I added or updated tests where appropriate.
  • This PR does not include secrets, credentials, production data, or private certificates/keys.
  • I updated documentation where necessary.
  • I linked the relevant issue for a feature or fix, or explained why no issue is needed.

Breaking changes

None. The handoff functions now reject repeatable read and serializable transactions, and a handoff inside a writer's own transaction. No caller exists yet.

Screenshots

None.

🤖 Generated with Claude Code

Address the CodeRabbit review of #560. None of the gaps was reachable
yet because no domain source is registered.

- Refuse the exclusive domain lock outside read committed and inside a
  transaction that already holds a writer's shared lock, so an export
  always reads after every fenced writer committed.
- Hold shared locks on every domain while the preview reads owners and
  source inspections, so a commit cannot land between both reads.
- Validate the serialized part text as well, treat throwing getters or
  toJSON hooks as invalid parts, and keep fire-and-forget rejections
  handled.
- Settle every accepted part before begin returns or rethrows.
- Document that retire may run again after a rolled-back commit.
- Scope test cleanup to rows the test created, check every ciphertext,
  prove the export waits behind a running writer and settle all
  transactions before cleanup.

Refs #457

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 35 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 288203b and 660e59c.

Files selected for processing: 5

  • web/src/server/LegacyHandoff/Types/legacy-handoff.types.ts
  • web/src/server/LegacyHandoff/journal.server.ts
  • web/src/server/LegacyHandoff/ownership.server.ts
  • web/src/tests/server/LegacyHandoff/journal.db.test.ts
  • web/src/tests/server/LegacyHandoff/ownership.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@RentnerKev
RentnerKev merged commit fe911d7 into main Nov 24, 2026
38 checks passed
@RentnerKev
RentnerKev deleted the rentner/fix/legacy-handoff-review branch November 24, 2026 21:02
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