Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: be17b9c597
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| }, { | ||
| orderBy: { dueAt: 'asc', jobId: 'asc' }, | ||
| limit, | ||
| lockMode: LockMode.PESSIMISTIC_PARTIAL_WRITE, |
There was a problem hiding this comment.
Make repair-cell claims transactional
When a reconciler calls this helper with a normal nontransactional EntityManager, MikroORM rejects the pessimistic lock; even if the query is executed in an implicit PostgreSQL transaction, that transaction releases the FOR UPDATE SKIP LOCKED locks before the rows are returned, allowing another replica to select the same cells. Require and verify a caller-owned transaction that performs the claim mutation before commit, or expose a callback that the helper runs inside its own short transaction.
AGENTS.md reference: packages/core/src/modules/progress/AGENTS.md:L91-L93
Useful? React with 👍 / 👎.
| cell: input.cell, | ||
| dueAt: input.dueAt, | ||
| reason: input.reason ?? null, | ||
| }, { onConflictAction: 'merge' }) |
There was a problem hiding this comment.
Fence stale repair-cell upserts
When two heartbeat or lease updates for the same job are delivered out of order, the unconditional conflict merge lets the older update overwrite the newer dueAt. The reconciler then either hot-loops on a cell whose authoritative lease is still live or removes it and loses the later expiry entirely, leaving a future orphan unrepairable. Include a monotonic lease epoch/version in the conflict predicate, or update dueAt only when the incoming write is still current.
AGENTS.md reference: packages/core/src/modules/progress/AGENTS.md:L91-L93
Useful? React with 👍 / 👎.
|
|
||
| export class Migration20260823084507_progress extends Migration { | ||
|
|
||
| override up(): void | Promise<void> { |
There was a problem hiding this comment.
Add a down migration for repair cells
When an operator rolls this migration back, there is no down() implementation to remove progress_job_repair_cells, so the schema rollback required by .ai/specs/2026-08-21-background-work-06-leased-jobs-in-progress.md:320 cannot restore the pre-change database state. Add a down migration that drops the index and table so rollback and subsequent forward migration remain reliable.
Useful? React with 👍 / 👎.
Implementation updateThe branch now includes durable repair-cell lease semantics:
Validation on the branch: focused progress tests pass (3 tests), package build passed, and the core package typecheck passed after generation. This still does not claim the full open-mercato#5450 implementation is complete. The next gates are integration with actual data-sync/workflow transitions and live Postgres/queue latency, crash, backlog-drain, and tenant-isolation tests. |
Verification updateImplemented
Passing
Postgres measured resultUsing equivalent tenant/org predicates and fixed batch size:
The small-table sequential plan is intentional PostgreSQL behavior; forcing an index there is slower. At material scale the candidate rows read remain bounded by the due batch rather than live-row count. Remaining red gateThe queue package suite is 101/104 passing. One directory-recreation wake-up test still times out after watcher recovery; the two ordinary event-wakeup tests pass. This is not being marked green until that test is fixed and the full queue suite is rerun. The benchmark artifact and scoped-query correction are in the private evidence repo commit |
Verification correctionThe earlier
The ordinary Jest process still reports an open-handle condition after all assertions complete. That remains an explicit cleanup gate; the result is not described as a clean Jest exit. The remaining PR #9 gates are real Postgres concurrent-claim/crash-recovery integration, Valkey worker-loss testing, workflow latency/RSS measurements, and the full upstream validation sequence. |
Codex findings addressedPushed in commit
Validation: core typecheck passed, focused repair-cell tests The direct |
|
The implementation lane has now been integrated with PR 8 onto the PR open-mercato#5450 base in integration PR 10. |
Purpose
Follow-up implementation for the PR open-mercato#5450 review staging branch. This is deliberately a separate PR so the review can distinguish the docs/spec lane from executable changes.
Included
progress_job_repair_cellswith tenant/org scope and a due-key index.Validation
yarn build:packagespassed.35/35passed, including recreated-directory recovery.104/104passed in approximately8.6swith--forceExit.git diff --checkpassed.Validation qualification
The queue assertions are green, but the ordinary Jest process still reports an open-handle condition after the suite.
--detectOpenHandles --forceExitcompletes all104/104tests; this is recorded as a remaining process-cleanup gate, not presented as a clean Jest exit.This branch is still not the complete PR open-mercato#5450 solution. Live Postgres concurrent-claim/crash-recovery integration, real Valkey worker-loss testing, workflow latency/RSS benchmarks, and full upstream validation remain open.