relayburn-sdk: gate gap-writer override behind test-utils feature#348
Conversation
Move `set_ingest_gap_writer` / `restore_ingest_gap_writer` (and their `pub use` re-exports) behind `cfg(any(test, feature = "test-utils"))`. The functions are test-only API for capturing stderr in unit tests; today they ship in the SDK's default public surface, where embedders can hijack the global gap-warning writer for the whole process. - Add `test-utils` feature to relayburn-sdk/Cargo.toml. - Gate the two function definitions in `ingest/gap.rs`. - Split the `pub use` block in `ingest.rs` so the writer hooks only re-export under the gate; non-writer items (`emit_gap_warning`, `record_session_gap`, `reset_ingest_gap_warnings`, etc.) stay public. `reset_ingest_gap_warnings` is left ungated because its doc explicitly calls out that it's safe to invoke from production code. Closes #338. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR restricts test-only gap writer override functions by introducing a ChangesTest-Utils Feature Gate
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
Gate
set_ingest_gap_writer/restore_ingest_gap_writer(and theirpub usere-exports) behindcfg(any(test, feature = "test-utils")). The functions are test-only API for capturing stderr in unit tests; today they ship in the SDK's default public surface, where embedders can hijack the global gap-warning writer for the whole process.test-utilsfeature torelayburn-sdk/Cargo.toml.ingest/gap.rs.pub useiningest.rsso only the writer hooks fall under the gate; the other gap helpers (emit_gap_warning,record_session_gap,reset_ingest_gap_warnings, etc.) stay on the default surface.reset_ingest_gap_warningsis left ungated because its doc explicitly says it's safe to invoke from production code.The audit for "other test-only-flavored exports" (per #338's scope item 5) found none — the only
Test-only:doc-tagged items in the SDK source are the two gated here andreset_ingest_gap_warnings(intentionally not gated).Closes #338.
Test plan
cargo build --workspace --all-targetsclean (default features — gate active)cargo test --workspacepasses — 729 tests, all green; in-crate tests reach the API viacfg(test)cargo build -p relayburn-sdk --features test-utils --all-targetscleanrg "set_ingest_gap_writer|restore_ingest_gap_writer" crates/relayburn-cli crates/relayburn-sdk-nodereturns nothing🤖 Generated with Claude Code