Skip to content

Make fetch deadline test deterministic across platforms - #871

Merged
Varuas37 merged 2 commits into
mainfrom
codex/870-deterministic-fetch-deadline
Oct 14, 2026
Merged

Varuas37 merged 2 commits into
mainfrom
codex/870-deterministic-fetch-deadline

Conversation

@Varuas37

@Varuas37 Varuas37 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

The macOS run for #834 timed out after 45 minutes with 2,939 of 2,940 server tests complete. The neighboring green #838 run completed the same suite, and the Rust source was unchanged between those heads. The unfinished test was a_fetch_whose_placement_read_stalls_is_timed_out_or_cancelled in crates/nessa-server/tests/conversation/leases.rs.

The test used a FIFO to make FilePlacements::placement block in a synchronous read. Dropping the async fetch future cannot cancel that physical syscall, and cleanup relied on FIFO open/write timing. The logs identify the unfinished test but do not prove which macOS syscall was blocked. The FIFO setup came from f334199ce9 (#776).

Solution

The test now injects a ConversationPlacements implementation that delegates setup and erase to the real file store, then returns a pending future for armed reads and signals when each read starts. It asserts the typed timeout and caller-cancellation results, verifies no host ask occurred, and bounds each wait. This exercises the fetch service's async contract on every platform; it does not claim to cancel a physical filesystem read or fix a server product path.

flowchart LR
  subgraph Before
    A[Fetch test] --> B[FIFO placement file]
    B --> C[Blocking filesystem read]
    C --> D[Timing-sensitive FIFO cleanup]
  end
  subgraph After
    E[Fetch test] --> F[Injected placement port]
    F --> G[Pending future and read-entered signal]
    G --> H[Deadline or caller cancellation]
    H --> I[Typed refusal; no host ask]
  end
Loading

Verification

  • Final head 6608f4b16c23b177407d50c4ca41532fcc8ce1af: focused test passed, 1/1 in 0.12s.
  • Tokio time starts paused; after the injected read-entry signal, the test asserts the virtual Instant is unchanged, then explicitly advances by the configured fetch wait.
  • Adversarial check: a temporary 250ms wall-clock delay before the read-entry signal passed with paused Tokio time. The same delay with the pause removed failed the pre-deadline Instant assertion. Both temporary changes were restored.
  • Earlier independent branch-removal probes showed removing the application timeout hits the outer test bound, while removing only cancellation returns TimedOut instead of Cancelled; service source was restored and its SHA matched the original.
  • cargo fmt --all -- --check, git diff --check, and git show --check passed. Fresh full review of this head was clean.
  • CI for head 6608f4b is pending.

The test-only timing change addresses scheduler delay before the read-entry signal. The armed PendingPlacements path constructs but does not poll the underlying file-placement read. This does not claim to bound or cancel production filesystem syscalls.

Summary by CodeRabbit

  • Tests
    • Improved coverage of placement-read timeouts and cancellation, including verification that neither condition triggers a host fetch.
    • The tests now verify timeout and cancellation outcomes independently, confirming that no response was delivered in either case and that the host was not contacted. This coverage also checks that the timeout is reported after the configured wait period.

)

Replace the FIFO-based stall with an injected pending read so the timeout and caller-cancellation outcomes are deterministic on every OS. The FIFO version originated in f334199 (#776).

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a1d46d07-88bb-471d-b61a-ac1f901ad7e5
📥 Commits

Reviewing files that changed from the base of the PR and between 5f5f21e and 6608f4b.

📒 Files selected for processing: 1
  • crates/nessa-server/tests/conversation/leases.rs

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

📝 Walkthrough

The conversation lease tests now inject a placement store into the publishing-host harness. A pending-read test double replaces the FIFO setup and supports checks for timeout, caller cancellation, and no host fetch request.

Changes: Placement-read deadline tests

Layer / File(s) Summary
Inject pending placement reads into fetch tests
crates/nessa-server/tests/conversation/leases.rs
The harness accepts an injected placement store. The test double holds placement reads pending. The test checks timeout and cancellation results, both with delivered: false, and asserts that neither attempt requests a host fetch.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other · Severity of issue fixed: Low

Suggested reviewers: claude

Merge Risk: ⚪ Minimal · up to 6608f

This change only makes a lease timeout test deterministic and has no production behavior impact. No merge-blocking risk was found.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Issue #870 requires the fetch deadline tests to use the injected ConversationPlacements port. The change adds PendingPlacements, signals placement-read entry, and keeps the read pending. The test …
Out of Scope Changes check Passed The reported change is limited to crates/nessa-server/tests/conversation/leases.rs. The harness parameter and PendingPlacements test double support issue #870. The change does not modify the produ…
Title check Passed The title clearly and concisely describes the main change: making the fetch deadline test deterministic across platforms.
Description check Passed The description clearly explains the motivation, injected pending placement implementation, expected timeout and cancellation behavior, verification steps, and scope. The repository template applies o…
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 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.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f5f21e3da

ℹ️ 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".

@chatgpt-codex-connector

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-14T13:38:47.253197Z 5f5f21e 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.

Pause Tokio time in the placement-read test and advance it only after the injected read-entered signal, so pre-read scheduler delay does not consume the deadline. Assert virtual time is unchanged before entry.

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@Varuas37
Varuas37 merged commit 4b8f393 into main Oct 14, 2026
11 checks passed
@Varuas37
Varuas37 deleted the codex/870-deterministic-fetch-deadline branch October 14, 2026 16:19
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