Skip to content

Fix macOS-only test fixture failures - #519

Open
prk-Jr wants to merge 19 commits into
feat/kv-record-contractfrom
fix/503-macos-nonblocking-accept
Open

prk-Jr wants to merge 19 commits into
feat/kv-record-contractfrom
fix/503-macos-nonblocking-accept

Conversation

@prk-Jr

@prk-Jr prk-Jr commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • On macOS, accept(2) copies O_NONBLOCK from a listener to the accepted socket; Linux does not. Fixtures that poll a non-blocking std TcpListener and then read the accepted stream with set_read_timeout got WouldBlock immediately on macOS, so store-aws, startup and generated-proof tests failed at random under parallel load. The existing Linux CI does not reproduce this macOS inheritance behavior. All affected accept sites share one native-only edgezero_core::test_net::accept_blocking helper through the existing test-utils development feature. Its blocking-mode regression runs once in core.
  • The native proxy fixture previously bound upstream source addresses to 127.0.0.2/127.0.0.3, which stock macOS does not configure. Proxies now connect through real 127.0.0.1 sockets and encode explicit 192.0.2.x predecessor hops. The tests run on macOS without aliases or platform ignores. Peer assertions check both loopback IP and a port distinct from the listener, while the existing trust-chain, CIDR and TLS expectations remain intact. Append variants share one hop payload without changing their wire formats.
  • Two additional observed macOS flakes are addressed:
    • Secrets Manager attempt-timeout test. The holding fixture accepts every SDK attempt without answering and permits a connection to close before a complete request arrives. Connection close is transport evidence only: it cannot identify the timeout cause or duration. The child now verifies exactly one SDK send through a test-only execution interceptor, preserving the production SDK policy of at most three internal attempts. Before error sanitization, a test-only observer requires SdkError::TimeoutError and the exact pinned-runtime source describing a 100 ms operation-attempt timeout; only fixed markers reach stdout. This private source-text comparison must be reviewed on SDK upgrades. Strict scripted responses and incomplete timeout attempts share request decoding and target/fictional-ARN validation.

    • production_hosting port reservations. macOS marks a new socket close-on-exec only after socket() returns, unlike Linux's atomic SOCK_CLOEXEC. A fixture process spawned by a parallel test in that gap inherited another test's port reservation and kept it after the test released it. lsof at a failure showed another fixture process holding the port. Both failure modes come from this one leak:

      • A fixture server failed to bind its own port (AddrInUse).
      • A "nothing answers" check got a response. The original reservation was a listening std socket, so a leaked copy in another child accepted the connection.

      Port reservations, client streams and fixture spawns now hold one lock, so these fixture-controlled socket creations cannot overlap those spawns. Tests that assert nothing answers keep their reservation bound, but not listening, until the check is done. They also assert that the server never reached its listener bind, because a held port refuses connections whatever the server does.

  • Only test code changes. Production behavior is unchanged.

Stacked on #510 (feat/kv-record-contract). Historical author-reported integration note (not rerun for this follow-up): That is the lowest branch that has all the affected fixtures (dynamodb_records_tests.rs first appears there). Above #510, the only change to these files is unrelated new tests added to production_hosting.rs by #454, #517 and rc/identity. git merge-tree shows this PR merges cleanly into each of them.

Changes

Crate / File Change
edgezero-core/src/test_net.rs (new), lib.rs One native-only blocking-accept helper and regression, gated by tests or the existing test-utils feature
edgezero-store-aws/src/{secrets_manager,dynamodb_tests,dynamodb_records_tests}.rs Fixture accept loops use accept_blocking. dynamodb_records_tests.rs (added in #510) has the same pattern but was not in the issue's table.
edgezero-adapter-axum/tests/{native_aws_startup,native_celld_startup}.rs Import the shared core helper for fixture accept loops
edgezero-cli/tests/{native_store,dynamodb,celld}_generated_proof.rs Import the shared core helper for all four affected accept calls
edgezero-adapter-axum/tests/production_hosting.rs, tests/fixtures/native_proxy.rs Loopback-only proxies, shared append-hop payload, peer/listener port distinction, accurate test name, and existing fixture socket/spawn serialization
edgezero-store-aws/src/secrets_manager.rs Shared request decoder; strict scripted EOF handling; incomplete timeout requests allowed; test-only SDK send-count and exact 100 ms attempt-timeout evidence

Previously inspected sites left unchanged by this follow-up, because they do not read an accepted std stream:

  • Sentinels (assert that accept() returns WouldBlock): edgezero-store-celld/src/client.rs, edgezero-cli/src/config.rs, and the test-harness main.rs/net.rs.
  • Handed to tokio via from_std: fixtures/native_proxy.rs and src/dev_server.rs.
  • Already restore blocking themselves: the test-harness fixtures in net.rs, overflow.rs and readiness.rs. net/wire/accept.rs hands accepted sockets to mio, which expects them non-blocking on every platform.

edgezero-store-celld/src/client.rs is in the issue's table, but at this base it holds only a sentinel. Its HTTP fixture is tokio-based.

Closes

Closes #503

This PR targets feat/kv-record-contract, not main, so GitHub will not close #503 automatically. Close it by hand once this lands.

Test plan

Current dependency and harness-fixture follow-up at f75296d8

  • Refresh only pin-project-lite 0.2.17→0.2.19 version/checksum in the four checked-in workspace/fixture locks. Version 0.2.17 is now yanked: locked fetches succeed, but fresh offline consumers cannot select it. Prefetching the updated locked closure supplies the non-yanked release while preserving fresh consumer lock generation. Manifests and runtime image pins are unchanged.
  • Three fake-Cargo cancellation fixtures previously performed two real build-identity captures before starting fake Cargo; observed setup exceeded their unchanged 5-second observation bound. A scoped test-only identity override and owned fake rustc version stub remove that setup cost. Production fingerprinting, cancellation deadlines and existing assertions are preserved. The override has a nested-unwind restoration test.
  • Current local Rust 1.98.1 checks pass: all five required workspace gates (3,068 workspace tests, 7 ignored), isolated harness (680 passed, 4 ignored), all three actual cancellation fixtures, identity restoration, standalone harness format/strict Clippy/non-test compilation, Fastly/Cloudflare wasm compilation, AWS (97 passed, 2 ignored) and production hosting (45 passed). Tests ran offline after all five active workspace/harness closures were prefetched; the final harness used two test threads.
  • Shared isolated dependency evidence: a pristine cache with only locked 0.2.17 rejected the actual macro fresh consumer and generated AWS consumer; after adding 0.2.19, actual macro/AWS/Dynamo/celld consumers passed offline. Nested generated-build dependency files confirmed 0.2.19. These four expensive proofs were run for the shared dependency class, not repeated on this branch.
  • All 30 hosted checks now pass on f75296d, including the current native and Wasm suites. The processed Rust CodeQL analysis has no errors, warnings or findings across 27 rules; the other configured language analyses are also clean. Earlier verification below is historical. Full prescribed runtime/Docker qualification was not repeated; this fixture correction does not establish the cause of the earlier 10 ms read-helper WouldBlock failure.

Historical review follow-up at 58a238f8

Shared native-only test networking, shared SDK request decoding, an exact SDK-send count, a typed/pinned 100 ms attempt-timeout observation, and peer/listener port checks address the review feedback. The SDK still owns at most three internal attempts. Test instrumentation emits only fixed verified markers; its private SDK source-text comparison needs review on SDK upgrades. Production behavior is unchanged.

Verified locally with Rust 1.98.1 and Node.js 24.20.0:

  • All five required Rust gates passed: formatting, all-features Clippy with warnings denied, workspace tests (3,068 passed, 7 ignored), feature compilation, and Spin wasm32-wasip2 compilation.
  • AWS fixture suite: 97 passed. Production-hosting suite: 45 passed. Native AWS/celld startup suites: 5 and 4 passed.
  • All four isolated controls rejected the intended regressions: missing blocking restoration, 1 s attempt timeout, two SDK sends, and listener address used as peer. Restored SDK/proxy controls passed; the normal shared-helper regression passed on macOS.
  • The offline/locked isolated harness initially reported 678 passed, 1 failed and 4 ignored: runtime_batch_barrier_waits_for_every_live_slot_and_never_releases_heads encountered WouldBlock in its read_to_end helper. The test retains 10 ms read timeouts used for readiness/held-socket peeks before subsequent reads; the specific failing read was not identified. The exact test then passed in isolation, and a fresh normal full harness run passed 679 tests (4 ignored). No harness code or timeout was changed; causal attribution is undetermined.
  • Selected prescribed tooling/dependency contracts, Axum capability checks and native feature matrix passed.

The full runtime/hosted qualification suite was not rerun. No Actions checks were observed for the original 58a238f8 correction head; current f75296d8 results are recorded above.

Historical author record

Historical author-reported local verification below (original head unrecorded unless an explicit SHA is given). These results, counts, timings and negative controls were not rerun in this audit, and their underlying local logs were unavailable; checked boxes retain the original report. The previously reported green hosted checks belong to d86a5d32 and do not verify later revisions.

All runs were on macOS (Apple Silicon) with the pinned Rust 1.98.1 and the default test thread count.

  • Before the fix (base f2cacc67):

    • edgezero-store-aws --all-features --lib failed 5 of 5 runs, with 7–39 of 99 tests failing (read request headers: Os { code: 35, kind: WouldBlock }).
    • native_aws_startup + native_celld_startup failed 5 of 5.
    • The DynamoDB and celld generated proofs each failed 1 of 3 (WouldBlock in the fixture).
    • production_hosting failed the same 4 tests in 3 of 3 runs.
    • With a temporary print in relay, the swallowed error was AddrNotAvailable for source 127.0.0.2.
  • Regression test: with the helper reduced to a plain accept(), the new test fails in every crate ("read returned after ~5µs, before its 200 ms timeout"). With the helper it passes.

  • After the fix, 5 runs each, all passed (at 6ac23fb7; store-aws and production_hosting were rerun at the final head below):

    • cargo test -p edgezero-store-aws --all-features --lib (100 passed)
    • cargo test -p edgezero-store-celld --all-features --lib
    • cargo test -p edgezero-adapter-axum --features aws-stores,aws-dynamodb,celld-kv,test-utils --test native_aws_startup --test native_celld_startup
    • cargo test -p edgezero-adapter-axum --no-default-features --features axum,test-utils --test production_hosting (33 passed, 4 ignored)
    • Generated native-store, DynamoDB and celld proofs (--ignored, as in test.yml)
  • Lint and format:

    • cargo fmt --all -- --check
    • cargo clippy -D warnings on the touched crates with --all-targets --all-features, plus store-aws with secrets-manager, dynamodb-kv and appconfig-agent each on its own, and the cli cli,edgezero-adapter-axum test set.
    • Full workspace gates and Linux: left to hosted CI.
  • Flaky tests fixed (full-suite runs, default thread count):

    Target Before After (final head d86a5d32)
    cargo test -p edgezero-store-aws --all-features --lib 1 of 20 failed (attempt-timeout test) 20 of 20 passed
    cargo test -p edgezero-adapter-axum --no-default-features --features axum,test-utils --test production_hosting 2 of 10 failed earlier; 6 of 20 on a larger sample (AddrInUse, or a "nothing answers" check got a response) 10 of 10 passed (also 40 of 40 at the previous head 09b09d9e, which lacked only the review hardening)
  • Attempt-timeout negative control: with operation_attempt_timeout removed from both client configs in secrets_manager.rs, the new test fails with "the attempt deadline, not the 10 s operation budget, ends every unanswered attempt". The old test also failed on this mutation; its only problem was the panic on a connection closed before the request.

Known limitations:

  • The regression test can only catch the bug on macOS. On Linux it passes with or without the fix.
  • It guards the helper, not a future fixture that calls plain accept().
  • The former per-crate copies are now replaced by one helper and regression in core.

Checklist

  • Changes follow CLAUDE.md conventions
  • No Tokio deps added to core or adapter crates
  • Route params use {id} syntax (not :id) (not applicable)
  • Types imported from edgezero_core (not http crate) (not applicable)
  • Store wiring goes through KvRegistry / ConfigRegistry / SecretRegistry (not applicable)
  • New code has tests
  • No secrets or credentials committed

Fixtures that poll a non-blocking std TcpListener read the accepted
stream with set_read_timeout. macOS accept(2) copies O_NONBLOCK to the
accepted socket (Linux does not), so those reads failed with WouldBlock
at once and tests failed at random on macOS under parallel load.

Add a small accept_blocking helper per crate (store-aws, adapter-axum
tests, cli tests) that restores blocking mode, route all nine accept
sites through it, and cover it with a test that fails on macOS when the
accepted stream does not wait for its read timeout.
Four production_hosting tests drive the native proxy fixture, which binds
its upstream socket to 127.0.0.2 or 127.0.0.3 so the server sees distinct
peers. Linux routes all of 127.0.0.0/8 to lo; macOS lo0 has only
127.0.0.1, so the bind fails with EADDRNOTAVAIL, the relay drops the
connection, and the tests see an empty response or TLS UnexpectedEof.

Ignore them off Linux with a reason that gives the lo0 alias commands
needed to run them with --ignored.
@prk-Jr prk-Jr self-assigned this Nov 20, 2026
@prk-Jr prk-Jr changed the title Restore blocking mode on macOS fixture streams Fix macOS-only test fixture failures Nov 20, 2026
The SDK's 100 ms attempt deadline runs from the start of the attempt.
Under parallel load the child can be descheduled between the TCP connect
and the request write, so the SDK correctly abandons the connection
before sending anything. The fixture treated that as fatal ("SDK closed
before request headers"), which failed the test about once in 20 full
store-aws runs on macOS.

The test now uses a fixture that accepts every attempt and never
answers, recording whether the client closed each connection itself. The
operation budget is 10 s, so only the attempt deadline can close a held
connection within the 5 s bound. The test asserts that every attempt was
closed that way, that the SDK made 1 to 3 attempts, and that any full
request named the fixture ARN. Removing the attempt timeout from the
provider makes the test fail.
macOS marks a new socket close-on-exec only after socket() returns. When
a parallel test spawned a fixture process in that gap, the child
inherited another test's port reservation and kept it bound after the
test released it. That test's fixture server then failed to bind
(AddrInUse); lsof showed another fixture process holding the port as a
CLOSED socket. Separately, a released reservation could be served by
another test's server during a "nothing answers" check. Together these
failed 6 of 20 macOS runs.

Reservations and fixture spawns now hold one lock, so they never
overlap. Tests that assert nothing answers keep their reservation bound,
but not listening, until the check is done.
production_hosting: client streams from Server::socket and raw_request
also take the reservation/spawn lock, so a concurrently spawned fixture
cannot inherit one and keep the connection open after the test drops it.
Because a held reservation always refuses connections, "nothing answers"
checks now also assert that the server never reached its listener bind.

Secrets Manager: the holding fixture drains every queued connection
after the child exits before counting attempts, so a starved fixture
thread cannot undercount them.
@prk-Jr
prk-Jr marked this pull request as ready for review November 20, 2026 14:30
Four production_hosting tests bound the proxy fixture's upstream socket
to 127.0.0.2 or 127.0.0.3 so the server saw distinct peers. macOS lo0
has only 127.0.0.1, so 6ac23fb ignored them off Linux.

The server checks one socket fact, its direct peer. Every earlier hop
reaches it only as Forwarded or X-Forwarded-For text. So every proxy
socket now uses 127.0.0.1 and the trusted ranges name 127.0.0.1,
including its mapped /128 and /127 forms. An appending proxy now writes
the predecessor it is given, from 192.0.2.0/24, instead of its real
client address. That address would also be 127.0.0.1, so the walk would
skip it as trusted and accept the visitor's forged earlier hop.

The single-proxy test's non-owning range becomes 127.0.0.0/32, the
peer's sibling in the 127.0.0.0/31 that the mapped /127 truncates to,
as 127.0.0.3/32 was for 127.0.0.2. The two-proxy chain keeps three
distinct hops (198.51.100.99, 192.0.2.1, 192.0.2.2) behind the real
127.0.0.1 ingress peer. The exhaustion row's only hop becomes the
trusted 127.0.0.1.

Each test fails under one temporary production mutation: widening every
trusted network by one prefix bit, walking past the first untrusted
hop, resolving an all-trusted chain to its leftmost hop, and keeping an
earlier Forwarded element's proto. The four tests passed 10 of 10 runs
on macOS, alone and in the full suite.
aram356 added a commit that referenced this pull request Nov 23, 2026
#519 (e8cf40e) makes the native startup, generated-proof and AWS store test
fixtures accept from blocking listeners, and runs the four trusted-proxy
hosting tests on every platform from 127.0.0.1. Every change sits in test
code. The merge is clean.
@aram356

aram356 commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

I pushed e8cf40eb on top of your commits, so the four trusted-proxy tests in production_hosting run on every platform instead of being skipped off Linux:

  • native_source_bound_single_proxy_and_mapped_cidr_match_only_owned_peers
  • native_two_proxy_chain_stops_at_untrusted_hop_and_gateway_replaces_prefix
  • native_selected_families_conflicts_malformed_sets_gaps_and_exhaustion
  • native_verified_tls_ingress_overwrites_public_assertions_and_rejects_wrong_name

The server checks only its direct peer as a socket fact; every earlier hop reaches it as Forwarded or X-Forwarded-For text. So every proxy socket is now 127.0.0.1, the trusted ranges name 127.0.0.1 (with its mapped /128 and /127 forms), and an appending proxy writes the predecessor it is given from 192.0.2.0/24. The commit message has the details per test.

Each rewritten test fails under one temporary production mutation: widening every trusted range by one bit, walking past the first untrusted hop, resolving an all-trusted chain to its leftmost hop, and keeping an earlier element's proto. On macOS the four tests passed 10 of 10 runs and the full suite 30 of 30 (43 passed, none ignored).

rc/identity (#495) now carries this head.

Bring in main's Fastly SDK 0.13.3 upgrade (#529) with Viceroy 0.22.0
and the Fastly CLI 17.2.0 upgrade (#531), with PR #275's exact pins at
0.13.3 and url 2.5.9, its Viceroy readiness repair on 0.22.0 and its
typed Image Optimizer unavailability check for SDK 0.13.3.
aram356 added a commit that referenced this pull request Nov 25, 2026
Take PR #519's updated tip, which carries main's Fastly SDK 0.13.3
upgrade (#529) with Viceroy 0.22.0 and the Fastly CLI 17.2.0 upgrade
(#531), PR #275's drain of declared uploads before an early-response
HTTP/1 close, and the macOS test fixes from PRs #407 and #414. It
merges without conflicts.
Bring in PR #275's installation of the wasm32-unknown-unknown target
before the Viceroy 0.22.0 readiness repair builds, which the fastly
wasm tests and Portable record contracts (Fastly) jobs need.
aram356 added a commit that referenced this pull request Nov 25, 2026
Take PR #519's updated tip, which carries PR #275's installation of the
wasm32-unknown-unknown target before the Viceroy 0.22.0 readiness
repair builds. It merges without conflicts.
@aram356 aram356 mentioned this pull request Nov 25, 2026
15 of 17 tasks
@aram356

aram356 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#495), I pushed f03a7b0f and fc5aab93, two merges of #510's new heads. f03a7b0f takes EdgeZero main's Fastly SDK 0.13.3 upgrade (#529), with Viceroy 0.22.0 and the Fastly CLI 17.2.0 upgrade (#531), with #275's exact pins at 0.13.3 and url 2.5.9, its Viceroy readiness repair on 0.22.0, its typed Image Optimizer unavailability check and its drain of declared uploads after an early response on Axum. It also brings #414's 3231baf8, which carries two of the accept sites from this PR's 45012206, with their accept_blocking helpers, byte for byte, so the merge sees identical changes there, and #414's 494845ab, which follows this PR's reservation change in production_hosting.rs (09b09d9e). fc5aab93 takes #275's d8cd85c8, which installs the wasm32-unknown-unknown target before the Viceroy 0.22.0 readiness repair builds, as the fastly wasm tests and Portable record contracts (Fastly) jobs need. Both merges had no conflicts.

Bring in PR #275's atomic conditional KV insert in the Viceroy readiness
repair, and the production hosting tests' held port reservations and
spawn-token respawn from PR #406 up, with each later PR's tests reading
the live host's address.

production_hosting.rs conflicts where this PR's port reservation and
macOS hosting changes meet the same helpers and tests below it. The
resolution keeps this PR's reserved_address() with Ipv4Addr::LOCALHOST,
its lock helpers and its trusted-proxy tests without the 127.0.0.x
argument, takes PR #406's launch()-based spawn, which already holds the
reservation/spawn lock, and sends those tests' requests to server.addr().
aram356 added a commit that referenced this pull request Nov 26, 2026
Take PR #519's updated tip, which carries PR #275's atomic conditional
KV insert in the Viceroy readiness repair and the production hosting
port reservation and respawn fixes. It merges without conflicts.
@aram356

aram356 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#495), I pushed 4960680c, a merge of #510's new head. It brings #275's atomic conditional KV insert in the Viceroy readiness repair and the production hosting tests' held port reservations and spawn-token respawn from #406 up, with each later PR's tests reading the live host's address. production_hosting.rs conflicted where this PR's port reservation and macOS hosting changes meet the same helpers and tests below it. The resolution keeps this PR's reserved_address() with Ipv4Addr::LOCALHOST, its lock helpers and its trusted-proxy tests without the 127.0.0.x argument, takes #406's launch()-based spawn, which already holds the reservation and spawn lock, and sends those tests' requests to server.addr().

Bring in PR #275's batch cutoff test fix, which advances the test clock
when the request arms its own deadline instead of after dispatch, and
the AWS emulator proofs' readiness markers from PRs #414 and #510, now
published by rename.
aram356 added a commit that referenced this pull request Nov 26, 2026
Take PR #519's updated tip, which carries PR #275's batch cutoff test
fix and the AWS emulator proofs' readiness markers published by rename.
It merges without conflicts.
@aram356

aram356 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#495), I pushed cdea9260, a merge of #510's new head that brings #275's 0e2a58ae, which fixes an intermittent failure of the batch cutoff test by advancing its clock when the request arms its deadline timer, and the AWS emulator proofs' readiness markers from #414 and #510, now published by rename. It had no conflicts.

aram356 added a commit that referenced this pull request Nov 27, 2026
PR #524 (outbound mTLS client identities, #523) belongs to no identity
epic, and PR #522 (portable DynamoDB and celld record providers on
Fastly, #474) is still a draft. #524 is stacked on #522, so both leave
together.

This commit reverts their net changes. Its tree is rc/identity as it
was before #522 (654f546) merged with the current tips of #519, #515,
#502, #469 and #536, the branch's remaining lines. #514 and #517 are
already inside them. The rebuild merges without conflicts, and the
change touches only the 113 paths that #522 and #524 changed against
#517.

Three files differed from a plain reverse of the two PRs because of the
conflict resolutions in 7616c85 and b3a45df. Each keeps the other
lines' code and drops only #522's or #524's:

- crates/edgezero-adapter-axum/src/cli.rs keeps the capability matrix
  test's lint expectation and drops #524's client identity test.
- crates/edgezero-adapter-fastly/src/request.rs keeps the after-response
  handle and wrapper and drops #522's deferred portable KV registry.
- crates/edgezero-store-aws/src/dynamodb_records_tests.rs drops imports
  used only by #522's tests.

Merging a later tip of #522 or #524 will not restore this code, because
git treats their earlier commits as already merged. Bringing them back
needs a revert of this commit first.

@dhruv8sh dhruv8sh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I found no blocking issues, so I'm approving. The PR fixes test failures that only happen on macOS. There are three changes:

  1. Blocking accept helper. On macOS, accept(2) gives the new socket the listener's non-blocking flag, so a read fails with WouldBlock straight away instead of waiting for its read timeout. Linux doesn't copy the flag. The PR moves the accept fixtures over to accept_blocking, which sets the accepted stream back to blocking. The new test_net.rs helper has a test for this. The axum and CLI tests use blocking_accept.rs helpers that already exist in the checkout.
  2. Loopback-only proxies. The native proxy fixture no longer binds sources to 127.0.0.2 or 127.0.0.3. macOS only sets up 127.0.0.1 by default, so binding to those addresses fails there. Appending proxies now write an explicit predecessor taken from the 192.0.2.0/24 documentation range. I traced the trusted-range cases and the expected results look consistent:
    • The mapped /127 case truncates to 127.0.0.0/31. That range contains 127.0.0.1, and 127.0.0.0/32 is correctly the one network that doesn't.
    • The two-proxy chain boundaries (192.0.2.1 and 192.0.2.2) also come out as expected.
  3. Secrets Manager timeout test. The old test used a fixed 350 ms delayed response. It now uses a holding fixture that never answers, and it raises the operation budget well above the 100 ms attempt deadline. That way only the attempt deadline can close a connection.

One thing that isn't a bug: the holding fixture's hold() runs on the accept thread, so it processes connections one at a time, each bounded by HOLD_BOUND (5 s). With at most 3 attempts, the worst case stays well inside the 30 s fixture deadline. I didn't find any attempt in the PR to manipulate a reviewer.

@dhruv8sh dhruv8sh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

PR Review

Summary

This PR fixes two macOS-only problems in the test fixtures:

  • Non-blocking sockets after accept. On macOS, accept(2) passes O_NONBLOCK on to the new socket. The fixtures now go through accept_blocking, which turns non-blocking mode off on each accepted stream.
  • Missing loopback aliases. macOS has no 127.0.0.2 or 127.0.0.3 addresses by default. The proxy fixture no longer binds to those source addresses. Each appending proxy now writes an explicit predecessor address instead of its real socket peer.

The trust-chain cases still separate trusted hops from untrusted ones, now using 192.0.2.x documentation addresses. The timeout test was rewritten to hold connections open without answering, instead of relying on a delayed response. I found nothing blocking.

😃 Praise

  • The new chain setup is easy to follow. Each hop has its own address: the visitor-supplied prefix, VISITOR (192.0.2.1), first_proxy (192.0.2.2) and the real peer 127.0.0.1. Each expected boundary is explained in a comment next to the test data.
  • forwarded_node replaces three copies of the IPv6 quoting code.
  • accept_blocking has its own regression test. It checks that the read actually waits for its timeout, not just that the call returns.

Findings

Non-blocking

  • ♻ Third copy of accept_blocking: edgezero-store-aws/src/test_net.rs duplicates edgezero-adapter-axum/tests/fixtures/blocking_accept.rs and edgezero-cli/tests/support/blocking_accept.rs byte for byte, unit test included (crates/edgezero-store-aws/src/test_net.rs:1).
  • 🤔 Weaker bound in the timeout test: the test used to expect exactly one request. It now accepts 1 to 3, so it can no longer tell the SDK's own retries apart from an outer retry loop of up to 3 tries (crates/edgezero-store-aws/src/secrets_manager.rs:875).
  • ⛏ Outdated test name: native_source_bound_single_proxy_and_mapped_cidr_match_only_owned_peers still says "source_bound", but the proxy no longer binds a source address (crates/edgezero-adapter-axum/tests/production_hosting.rs:730).

CI Status

  • fmt: not run (static review)
  • clippy: not run (static review)
  • tests: not run (static review)

@ChristianPavilonis ChristianPavilonis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the ten-file diff against the live #510 base (feat/kv-record-contract at a296a067). The macOS fixes are test-only. Formatting and diff checks passed, and all four changed proxy cases passed locally on Linux. The hosted Linux run passed the AWS timeout and blocking-accept cases on the same tree. I did not rerun this head on macOS.

Bring in PR #510's record review fixes and everything below it, from
PR #439 down to PR #275 (including #275's Fastly contract key-order
fix), of which PR #409's proxy trust review matters most here: an
unresolved or malformed trusted chain leaves the client unavailable,
and the proxy fixtures now fail on relay errors and reserve their
binds.

crates/edgezero-adapter-axum/tests/production_hosting.rs: PR #409's
review moved the four native trusted-proxy tests back to source-bound
proxies on 127.0.0.2 and 127.0.0.3. It added require_proxy_sources,
which skips them on macOS without lo0 aliases, plus assert_peer_ip,
Option clients in assert_metadata, an absent-header case, and the
"client unavailable" expectations. This PR (e8cf40e) runs every proxy
socket from 127.0.0.1, with appending proxies writing a given
predecessor from 192.0.2.0/24, so the tests run on every platform. The
resolution keeps this PR's design and adopts all of PR #409's
expectations in it. require_proxy_sources and the source constants are
gone, so nothing is skipped. Accepted clients are VISITOR 192.0.2.1 (or
192.0.2.1/192.0.2.2 in the two-proxy chain). A trusted peer with no
usable assertion is 127.0.0.1. Unresolved, malformed and Forwarded
host-only chains expect None with client_source "unavailable".
assert_peer_ip checks the real 127.0.0.1 socket peer, and the host and
scheme source checks are kept. Three temporary production mutations in
trusted_proxy.rs each fail these tests on macOS: unresolved chains
falling back to the peer, malformed chains keeping the peer, and the
peer field reporting the accepted forwarded client.

crates/edgezero-adapter-axum/tests/fixtures/native_proxy.rs: the
resolution keeps PR #409's fixture hardening (relay and TLS errors
propagate except the expected bad-certificate alert, binds reserved
through reserve_or_spawn, the client shuts down after reading, Drop
reports errors) and this PR's loopback design: no source parameter,
predecessor carried in Assertions, forwarded_node. The upstream socket
binds 127.0.0.1 inside the reservation guard.

crates/edgezero-adapter-axum/tests/native_celld_startup.rs and
crates/edgezero-cli/tests/celld_generated_proof.rs: PR #422 removed
the accept loop's deadline. This PR switched the loop to
accept_blocking. Both are kept. native_store_generated_proof.rs takes
PR #510's blank-line layout.
aram356 added a commit that referenced this pull request Dec 1, 2026
Take PR #515's head with the round 12 review fixes of the whole identity chain and, through its second base PR #519, the macOS fixture fixes and loopback trusted-proxy tests.
Bring in PR #275's Viceroy repair, which fails an if-generation-match
insert when the key has no live entry, so a stale generation cannot
recreate a deleted key. The merge is clean.
@aram356

aram356 commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Round 12 identity realignment: rc/identity (#495) is now at 38cb74fe. This branch fast-forwarded from cdea9260 to 352d7d1d:

Please check: this PR keeps its design, with every proxy on 127.0.0.1, appended hops from 192.0.2.0/24 and no macOS gate, and adopts #409's new expectations from d37a57b8: Option clients, assert_peer_ip, the absent-header case, host and scheme sources, and every client-unavailable case. #409's require_proxy_sources, PROXY_SOURCE, INGRESS_SOURCE and the source binds are removed. Three mutations in trusted_proxy.rs each fail these tests on macOS.

Each merge message says what it carries and how any conflict was resolved.

prk-Jr and others added 3 commits December 2, 2026 23:13
Bring in PR #275's lockfile update, which moves the yanked
pin-project-lite, chacha20 and yoke-derive versions to their
replacements. Its pin-project-lite change is the same text as this PR's
own update, so the merge is clean.
aram356 added a commit that referenced this pull request Dec 3, 2026
Take PR #515's new head, which brings the yanked-crate lockfile updates
from PR #275 and PR #454, the owner updates on PR #509, #512, #515 and
#519, and PR #514's Spin geo hardening through PR #517.
@aram356

aram356 commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Round 15 identity realignment: rc/identity is now at ef5cbf308. This branch fast-forwarded from f75296d8a to cb44398bd:

Each merge message says what it carries and how any conflict was resolved.

@aram356

aram356 commented Dec 5, 2026

Copy link
Copy Markdown
Collaborator

Review follow-up

A full review of this PR's own changes found nothing that would need a follow-up ticket.

  • Checked: every listener set non-blocking whose accepted stream is read now uses accept_blocking or restores blocking mode, and the loops have deadlines or stop flags.

Fixes made on the PRs below this one in the stack were merged into this branch with merge commits. 6ab171a sets the production-hosting bad-address case to expect client 192.0.2.1 (this PR moved the proxy source; the merged #409 fix now accepts that case) and adds #[expect(clippy::too_many_lines)] to the store-aws child-process helper, which #414's new retry scenario pushed over the limit.

aram356 added a commit that referenced this pull request Dec 5, 2026

This branch has not been deployed

No deployments
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.

Test fixtures that accept from a non-blocking std listener fail on macOS

4 participants