Skip to content

test(jobstore): port fenced scheduler pull parity (PL-141–143) - #23929

Closed
Git-on-my-level wants to merge 3 commits into
mainfrom
lane/parity-pl141
Closed

Git-on-my-level wants to merge 3 commits into
mainfrom
lane/parity-pl141

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

The scheduler contention repair in #23927 added fenced pull ownership to every Store adapter, but its behavioral regression covered Firestore and a unit fake. A migration could retain the interface while losing the no-write, expiry or rollback guarantee on Postgres. This adds the same production-Scheduler cases to the existing Store conformance matrix for old Firestore, new Postgres and the single-threaded simulator.

  • PL-141: a busy follower touches no queue/control read set and writes nothing, including its claim. Postgres's separate claim-acquisition transaction remains permitted.
  • PL-142: exact claim expiry and token replacement each fence a paused holder before job mutation or claim release; reconstruction respects the replacement's live deadline.
  • PL-143: an abort after the real pull body buffers its lease/release rolls both back; after bounded expiry a reconstructed scheduler issues each original job once at attempt one. Issued job leases remain exclusive.

The existing shared primitive is the real Scheduler plus Store.acquire_pull_claim; the change exercises it through the established testing/store_fixtures.py matrix. It introduces no alternate implementation. The fixture also removes its own throwaway Firestore pull-claim documents. The existing backend/scripts/run-emulator-proofs.sh invocation now requires the simulator and Firestore legs (a caller can require all three). Updating this script also selects the existing proof workflow, whose path filter does not include changes to the suite itself; no workflow change is needed.

Validation:

  • Through workspace bin/omi-heavy, OMI_REQUIRE_STORE_BACKENDS=all, a dynamically allocated loopback Firestore emulator, anonymous synthetic customer data and throwaway Unix-socket Postgres: PYTHONPATH=backend backend/.venv/bin/python -m pytest -q -p no:cacheprovider backend/tests/integration/test_store_conformance.py — 101 passed, one pre-existing simulator concurrency skip. New cases: 12 passed, zero skips/xfails.
  • PYTHONPATH=backend backend/.venv/bin/python -m pytest backend/tests/unit/test_store_fixtures_iam.py -q — 2 passed.
  • The complete backend/scripts/run-emulator-proofs.sh runner also passed through omi-heavy with all three stores required, including the new Store matrix. bash -n passed for the runner.
  • Repository preflight and final normal push gates passed (33 selected preflight checks), as did metadata validation, pinned Black and diff hygiene. The full backend typecheck has zero errors.

This qualifies the existing interface locally; it does not measure deployed throughput or establish recovery of production projection debt. The companion KB ledger and Plan A acceptance carry PL-141/142/143. Merge remains lead-owned.

Product invariants affected

none

Failure-Class: FC-unowned-scheduler-shard-writes

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T00:55:40.232437Z 75eca97 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Git-on-my-level
Git-on-my-level marked this pull request as draft November 4, 2026 07:01
@Git-on-my-level
Git-on-my-level marked this pull request as ready for review November 4, 2026 07:27

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found across 3 files

Confidence score: 4/5

  • backend/scripts/run-emulator-proofs.sh can pass without testing the sim or emulator backends when OMI_REQUIRE_STORE_BACKENDS=postgres. Require both backends for this proof.
  • backend/tests/integration/test_store_conformance.py misses the control query because Scheduler.pull calls control_candidate before the store.run wrapper. Spy on control_candidate to verify the no-control-read guarantee.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/scripts/run-emulator-proofs.sh">

<violation number="1" location="backend/scripts/run-emulator-proofs.sh:78">
P2: This preserves an inherited selector that can disable the required legs: with `OMI_REQUIRE_STORE_BACKENDS=postgres`, missing sim and emulator backends skip and this proof can pass without testing them. Force `sim,emulator` for this runner, or normalize caller-supplied values so those two backends are always required.</violation>
</file>

<file name="backend/tests/integration/test_store_conformance.py">

<violation number="1" location="backend/tests/integration/test_store_conformance.py:490">
P2: This assertion does not verify the claimed no-control-read guarantee: `Scheduler.pull` calls `control_candidate` before the `store.run` wrapper, so its control query is invisible to `reads`. Spy on `control_candidate` or add backend-level read instrumentation, then assert the busy path performs no control/queue reads.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

# Includes PL-141/142/143 scheduler pull ownership, expiry and abort/restart recovery.
# Sim + Firestore must execute here; Postgres is qualified locally with all backends required.
run_proof "job-store conformance (sim + emulator, including fenced scheduler pulls)" \
env "OMI_REQUIRE_STORE_BACKENDS=${OMI_REQUIRE_STORE_BACKENDS:-sim,emulator}" \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: This preserves an inherited selector that can disable the required legs: with OMI_REQUIRE_STORE_BACKENDS=postgres, missing sim and emulator backends skip and this proof can pass without testing them. Force sim,emulator for this runner, or normalize caller-supplied values so those two backends are always required.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/scripts/run-emulator-proofs.sh, line 78:

<comment>This preserves an inherited selector that can disable the required legs: with `OMI_REQUIRE_STORE_BACKENDS=postgres`, missing sim and emulator backends skip and this proof can pass without testing them. Force `sim,emulator` for this runner, or normalize caller-supplied values so those two backends are always required.</comment>

<file context>
@@ -72,9 +72,10 @@ run_proof "summary task recovery, concurrency and expiry" \
+# Includes PL-141/142/143 scheduler pull ownership, expiry and abort/restart recovery.
+# Sim + Firestore must execute here; Postgres is qualified locally with all backends required.
+run_proof "job-store conformance (sim + emulator, including fenced scheduler pulls)" \
+  env "OMI_REQUIRE_STORE_BACKENDS=${OMI_REQUIRE_STORE_BACKENDS:-sim,emulator}" \
   "$PYTHON" -m pytest -q -p no:cacheprovider tests/integration/test_store_conformance.py
 
</file context>

assert queue.pull(1001) == []
# Postgres acquires through a transaction; Firestore uses conditional CAS.
# Neither may enter the queue/control read set or write anything when busy.
assert set(reads) <= {'pull_claims'} and writes == []

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: This assertion does not verify the claimed no-control-read guarantee: Scheduler.pull calls control_candidate before the store.run wrapper, so its control query is invisible to reads. Spy on control_candidate or add backend-level read instrumentation, then assert the busy path performs no control/queue reads.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/tests/integration/test_store_conformance.py, line 490:

<comment>This assertion does not verify the claimed no-control-read guarantee: `Scheduler.pull` calls `control_candidate` before the `store.run` wrapper, so its control query is invisible to `reads`. Spy on `control_candidate` or add backend-level read instrumentation, then assert the busy path performs no control/queue reads.</comment>

<file context>
@@ -427,3 +430,138 @@ def body(tx):
+    assert queue.pull(1001) == []
+    # Postgres acquires through a transaction; Firestore uses conditional CAS.
+    # Neither may enter the queue/control read set or write anything when busy.
+    assert set(reads) <= {'pull_claims'} and writes == []
+    monkeypatch.setattr(h.store, 'run', run)
+    assert snapshot() == before
</file context>

# Conflicts:
#	backend/tests/integration/test_store_conformance.py
Git-on-my-level added a commit that referenced this pull request Nov 4, 2026
# Conflicts:
#	backend/scripts/run-emulator-proofs.sh
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Folded into survivor #24591 (lane/lcinv, pushed head b8e0b1e0b3). As part of consolidating the open PR batch, origin/main and every other listed PR were merged into the survivor branch; all tests were kept. This PR is being closed as folded — its content lives on in #24591.

Merged, with one deliberate exception: the formatting-only change to omi/firmware/omi/src/safe_mode.c (compound-literal brace space, clang-format 19+ dialect) was not carried — origin/main's CI-green blob (046a191890) is byte-identical in the folded tree. The PL-141/142/143 fenced-scheduler-pull coverage in test_store_conformance.py and the widened run_proof (sim,emulator) were carried.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Hey @Git-on-my-level 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

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