Skip to content

fix(hydrate): gate posix_fadvise to Linux/Android, not cfg(unix) - #1208

Merged
AdaWorldAPI merged 1 commit into
mainfrom
claude/hydrate-fadvise-macos
Sep 6, 2026
Merged

fix(hydrate): gate posix_fadvise to Linux/Android, not cfg(unix)#1208
AdaWorldAPI merged 1 commit into
mainfrom
claude/hydrate-fadvise-macos

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Sep 6, 2026

Copy link
Copy Markdown
Owner

The defect

crates/lance-graph-hydrate/src/release.rs gated three sites #[cfg(unix)] and called libc::posix_fadvise / libc::POSIX_FADV_DONTNEED inside them.

posix_fadvise is a Linux/Android extension, not POSIX-universal — Apple's libc does not declare it — so the crate fails to compile on macOS:

error[E0425]: cannot find function `posix_fadvise` in crate `libc`
error[E0425]: cannot find value `POSIX_FADV_DONTNEED` in crate `libc`

cfg(unix) reads as "has fadvise" and is not. This is a real break on main, not something this branch introduced.

The fix

The three sites are gated #[cfg(any(target_os = "linux", target_os = "android"))], and the existing fallback arm's negation widens to cover macOS/BSD. The doc comment records the rule so the gate is not re-widened by intuition:

Widen this gate only to targets whose libc actually declares the call.

One file, +15/−6. No behaviour change on Linux.

Verification

  • cfg selection proved two-sidedly on the pinned 1.98.1 toolchain with a #[no_std] rustc probe: x86_64-apple-darwin compiles clean (Linux arm excluded); x86_64-unknown-linux-gnu hits the deliberate marker error (Linux arm selected). So the failure is target-OS-driven, not arch-driven — an x86 macOS runner catches it, an aarch64 Linux one does not.
  • 39/39 crate tests green on Linux, including the three in release.rs.
  • cargo fmt -p lance-graph-hydrate -- --check and cargo clippy -p lance-graph-hydrate --all-targets -- -D warnings both clean.

Honest caveat: the crate was not compiled end-to-end for darwin here — ring needs a C toolchain this sandbox lacks. The macOS half rests on the cfg proof above plus CI.

Board hygiene

Files ISS-NO-NON-LINUX-TARGET. Neither existing issue covers this one, and the difference is the generalization:

filed issue axis why it misses this
ISS-NO-AARCH64-RUNNER target arch this is target OS; x86 macOS fails too
ISS-EXCLUDED-CRATES-UNBUILT member list lance-graph-hydrate is a member CI compiles every PR

The accurate statement is the union: CI compiles exactly one (target_os, target_arch, crate-list) tuple(linux, x86_64, members). Everything outside it is text the parser skips. This week's three defects fall one on each axis, which is why fixing any single axis would not have caught the other two.

Found by q2's newly-ungated macos-latest job — a downstream consumer's CI doing this repo's job, for the third time in one week.

Not fixed here: the axis itself. A macos-latest job (or a cheap cargo check --target x86_64-apple-darwin on the existing x86 runners) is a CI policy change and an operator call, not a drive-by on a compile-fix PR. The cheap form needs rustup target add --toolchain 1.98.1 <target> — installing for the default toolchain while the repo pins 1.98.1 yields a can't find crate for 'core' that reads like a broken probe rather than a missing std.

Downstream

Unblocks macOS CI on q2 main and q2 #147.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AGVLyRZNEKKBSfBDJfbY3V


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Fixed compilation failures on macOS and BSD systems by limiting posix_fadvise support to Linux and Android.
    • Other Unix-like platforms now use the fallback file-counting behavior.
  • Documentation

    • Documented the lack of non-Linux target coverage and the related portability issue.

`release.rs` gated three sites `#[cfg(unix)]` and called
`libc::posix_fadvise` / `libc::POSIX_FADV_DONTNEED` inside them.
`posix_fadvise` is a Linux/Android extension, not POSIX-universal —
Apple's libc does not declare it — so the crate failed to compile on
macOS with `error[E0425]: cannot find function 'posix_fadvise' in
crate 'libc'`. `cfg(unix)` reads as "has fadvise"; it isn't.

The three sites are now gated
`#[cfg(any(target_os = "linux", target_os = "android"))]`, with the
existing fallback arm widened to cover macOS/BSD, and a doc comment
recording the rule: widen this gate only to targets whose libc
actually declares the call.

Verification:
- cfg selection proved two-sidedly on the pinned 1.98.1 toolchain with
  a `#![no_std]` rustc probe — `x86_64-apple-darwin` excludes the Linux
  arm, `x86_64-unknown-linux-gnu` selects it. The failure is
  target-OS-driven, not arch-driven.
- 39/39 crate tests green on Linux (incl. the 3 in `release.rs`);
  `cargo fmt --check` and `clippy -p lance-graph-hydrate --all-targets
  -- -D warnings` clean.
- Not compiled for darwin end-to-end here: `ring` needs a C toolchain
  this sandbox lacks. The macOS half rests on the cfg proof plus CI.

Board: files `ISS-NO-NON-LINUX-TARGET`. Neither existing issue covers
this one — `ISS-NO-AARCH64-RUNNER` is about target arch, and
`ISS-EXCLUDED-CRATES-UNBUILT` is about the member list, while
`lance-graph-hydrate` is a member that CI compiles on every PR. The
accurate statement is the union: CI builds exactly one
(target_os, target_arch, crate-list) tuple, and this week's three
defects each fall on a different one of those axes.

Found by q2's newly-ungated macos-latest job — a downstream consumer's
CI doing this repo's job, for the third time in one week.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AGVLyRZNEKKBSfBDJfbY3V
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: 3bb80857-f0a0-463e-96a2-da245548551d

📥 Commits

Reviewing files that changed from the base of the PR and between 2918421 and 885cf3a.

📒 Files selected for processing (2)
  • .claude/board/ISSUES.md
  • crates/lance-graph-hydrate/src/release.rs

Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.


📝 Walkthrough

Walkthrough

The release code now enables posix_fadvise only on Linux and Android. Other targets use a counting fallback. The issue board records the macOS compilation failure and the remaining non-Linux CI coverage gap.

Changes

Non-Linux platform support

Layer / File(s) Summary
Linux and Android advisory gate
crates/lance-graph-hydrate/src/release.rs
The file advisory implementation and documentation now target Linux and Android only.
Fallback behavior and issue tracking
crates/lance-graph-hydrate/src/release.rs, .claude/board/ISSUES.md
Non-Linux and non-Android targets count entries without calling posix_fadvise. The issue record documents the macOS failure and CI coverage gap.

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

Merge Risk: ⚪ Minimal · up to 885cf

This change prevents macOS and BSD builds from compiling an unavailable advisory API while preserving Linux and Android behavior. No actionable merge risk remains.

Suggested reviewers: claude

Poem

A rabbit hops where build flags gleam
Linux and Android share the stream
Mac counts files with steady care
BSD finds no broken snare
The issue board records the trail

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: restricting posix_fadvise compilation to Linux and Android instead of all Unix targets.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. (1 skipped: 1 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@cursor

cursor Bot commented Sep 6, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_90aa7b8a-a29e-43d4-b009-e883f1a4db14)

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review September 6, 2026 16:03
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@AdaWorldAPI
AdaWorldAPI merged commit a5a7c93 into main Sep 6, 2026
11 checks passed
AdaWorldAPI pushed a commit to AdaWorldAPI/q2 that referenced this pull request Sep 6, 2026
macOS CI failed to compile cockpit-server:

    error[E0425]: cannot find function `posix_fadvise` in crate `libc`
    error[E0425]: cannot find value `POSIX_FADV_DONTNEED` in crate `libc`
    error: could not compile `cockpit-server` (bin "q2-cockpit")

`advise_dontneed` in osm_slab_hydrate.rs was gated `#[cfg(unix)]` with a
`#[cfg(not(unix))]` no-op beside it. `posix_fadvise` is a Linux/Android
extension, not POSIX-universal — Apple's libc does not declare it — so
`cfg(unix)` reads as "has fadvise" and is not. The function's own doc
comment stated the wrong premise ("No portable equivalent exists ... on
non-Unix targets"), which is what made the gate look correct.

This is the SECOND instance of this exact defect today. The first was in
lance-graph (AdaWorldAPI/lance-graph#1208, merged); q2 carries its own
independent copy in this file. Fixing lance-graph's did not fix this one,
and the macOS job moved from failing in `lance-graph-hydrate` to failing
here — same error, different crate.

Fix (identical to #1208): gate both arms on the OS that actually has the
call, and record the rule in the doc comment so the gate is not re-widened
by intuition.

Both arms still bump the `#[cfg(test)]` FADVISE_ATTEMPTED counter, so the
reachability test is unaffected on either platform.

Verification — red-then-green on the REAL CI target (macos-latest is Apple
Silicon), compiling the gate pair against the real `libc` crate:

    new gate,  aarch64-apple-darwin        compiles OK
    new gate,  x86_64-unknown-linux-gnu    compiles OK
    OLD cfg(unix) control, aarch64-darwin  reproduces both E0425s exactly

Plus a two-sided `#![no_std]` cfg probe on the pinned 1.98.1 toolchain:
x86_64/aarch64-apple-darwin exclude the Linux arm; x86_64-unknown-linux-gnu
selects it. `cargo fmt -p cockpit-server -- --check` clean.

NOT verified here: a full `cargo check -p cockpit-server` in either
configuration. This sandbox cannot build that dependency tree (lance +
datafusion + deno exhaust the disk), and cross-compiling it for darwin
additionally needs a C toolchain for `ring`. The change is three cfg
attributes and a doc comment, and the gate pair itself is compile-proven
above against real libc on both targets.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AGVLyRZNEKKBSfBDJfbY3V
AdaWorldAPI pushed a commit that referenced this pull request Sep 7, 2026
`main` moved 2918421 -> d24ddbc (#1208/#1209/#1210) and made this PR
`mergeable_state: dirty`. One conflict: both sides prepended a board entry to
LATEST_STATE.md. Both survive -- this branch's Blocks V3 contract entry above
main's #1209 record, in prepend order. 3384 lines against parents of 3324 and
3305, so no-shrink holds against both.

Corrected in the same resolution rather than merged forward: this entry's
citation-decay paragraph claimed the gate was red on origin/main too, 12
findings byte-identical, and that its prescribed fix would require editing
past entries the append-only rule protects. That described one run and was
carried forward instead of re-read. On dcfc820 the gate reported 1 NEW decay
and it was this branch's -- registering the class moved the NodeRow size
assert off the line ISSUES.md:1537 cited. Fixed in 91fb423 with a stable
anchor; the "append-only forbids it" dilemma was false, since an anchor repair
changes a citation's address, not a past entry's claim.

citation-decay --since d24ddbc: 0 new decay(s), 147 pre-existing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011DN5odWu4eisdevH9bPWyz
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.

2 participants