Skip to content

Harden core runtime contracts - #208

Draft
wangxiao1254 wants to merge 7 commits into
fix/wan-socket-policyfrom
audit/core-contracts
Draft

wangxiao1254 wants to merge 7 commits into
fix/wan-socket-policyfrom
audit/core-contracts

Conversation

@wangxiao1254

Copy link
Copy Markdown
Member

Summary

Tighten fail-stop, deterministic-test, utility, transpose, task-lifecycle, and aligned-storage contracts in the runtime core.

Changes

  • flush fatal diagnostics before fail-stop termination;
  • require exact deterministic test-mode activation;
  • reserve lane zero for the owner thread and derive child/task lanes deterministically;
  • reject invalid lane IDs and zero-worker pools;
  • define null-pointer behavior for zero-length block helpers and reject negative lengths;
  • strictly parse party IDs and EMP_PORT;
  • use steady_clock consistently for elapsed timing;
  • validate bit-packing lengths;
  • fix portable SIMD header bootstrap and every 8-row transpose remainder;
  • drain all futures before rethrowing the first task failure;
  • make ThreadPool construction exception-safe and derive result types from the stored invocation category;
  • remove unused generic macros from the public umbrella;
  • add direct BlockVec alignment, copy/move, reserve, and lifetime coverage.

Compatibility and cost

The runtime remains exception-free at its public boundary and continues to build with -fno-exceptions. Task exceptions, where enabled internally through std::future, are rethrown only after the whole submitted batch is drained.

No protocol wire format changes. The checks are construction, parsing, failure, or batch-boundary checks; gate and crypto loops are unchanged.

Tests

  • clean Apple Clang 17 Release/Ninja build completed;
  • full CTest suite: 55/55 passed;
  • focused core suite: 7/7 passed (test_block, test_block_vector, test_error, test_test_mode, test_thread_pool, test_utils, and test_no_exceptions);
  • portable Release (EMP_TOOL_NATIVE_ARCH=OFF): focused suite 7/7 passed.

Focused coverage includes block helpers, BlockVec, error handling, deterministic test-mode threading, ThreadPool, utilities, transpose reference comparisons, and the exception-disabled umbrella build.

Stack

This is PR 3 of 6 and targets fix/wan-socket-policy.

Accept byte-bool buffers in bit packing, PRG output, packed IOChannel transfers, F2k selectors, and Galois-field packing without casting them to bool pointers.

Share implementations with the existing bool overloads. Preserve null-safe zero-length calls, normalize byte-bool output, and keep the bool and uint8_t paths bit-, wire-, and PRG-state-equivalent.
Expose explicit send and receive socket-buffer sizes through NetIO and TLSConfig. Apply them before listen/connect and the TLS handshake, propagate them to NetIO siblings, and leave operating-system defaults unchanged when both values are zero.

Provide an opt-in bandwidth/RTT helper that rounds the bandwidth-delay product to a power-of-two tier and reject explicit sizes the kernel cannot provide.
Remove the transport-level sync hook and preserve connection coverage with explicit protocol round trips. Callers that need a peer barrier must exchange a protocol message; flush only drains local output.

Fail on NetIO stdio flush errors. Make TraceIO reject null transports, flush its trace before the wrapped channel, create trace files with mode 0600, and report trace write and flush failures.
Flush fatal diagnostics before terminating. Require exact deterministic-test activation, reserve lane zero for the owner thread, derive child lanes deterministically, and reject invalid lane and ThreadPool configurations.

Add focused fail-stop, deterministic threading, and pool-lifecycle coverage.
Accept null pointers only when a block-array operation has length zero and reject negative lengths before pointer arithmetic. Add direct zero-length and invalid-length coverage.
Strictly parse party and port inputs, preserve the steady-clock type through timing helpers, and validate bit-packing lengths.

Fix the portable SIMD include bootstrap and handle every remainder row in the scalar transpose tail. Add independent scalar-reference and utility boundary tests.
Drain every future before rethrowing the first task failure, preserve exception-disabled builds, and remove unused generic macros from the public umbrella.

Make ThreadPool construction exception-safe, derive result types from the stored invocation category, and retain move-only task support. Add direct BlockVec ownership and alignment coverage.
@wangxiao1254
wangxiao1254 force-pushed the fix/wan-socket-policy branch 2 times, most recently from 3c84449 to 030bf9e Compare August 23, 2026 02:45
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