feat(quarantine): send test collection id and record resolution mode - #1147
Merged
Conversation
Pipe the existing --test-collection-id value into the getQuarantineConfig request (testCollectionShortId) and record the response's new quarantineResolutionMode field in telemetry, across both the traditional and rspec invocation paths. - api: add test_collection_short_id to GetQuarantineConfigRequest and quarantine_resolution_mode (Option, serde default) to the response so older servers that omit it still deserialize. - populate test_collection_short_id from meta (traditional) and from TRUNK_TEST_COLLECTION_ID (rspec). - proto: add QuarantineResolutionMode enum and UploadMetrics field 9; carry the mode through QuarantineContext and a RunUploadOptions override. - emit a Sentry-only tracing event (hidden_in_console) with the resolved mode in both paths for debugging. Server side: trunk-io/trunk#33132 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details. |
TylerJang27
approved these changes
Jul 24, 2026
| anyhow::Result::Ok(response) => (Some(response), QuarantineFetchStatus::FetchSucceeded), | ||
| anyhow::Result::Ok(response) => { | ||
| // Surface which source the server resolved quarantine status from. Sent to Sentry | ||
| // only (hidden from the console) to aid debugging without adding CLI noise. |
Collaborator
There was a problem hiding this comment.
Imo would be preferable to include a visible log for it if test collection id is set
| quarantined_tests.insert(quarantined_test_id.clone(), true); | ||
| } | ||
| // Surface which source the server resolved quarantine status from. Sent to Sentry | ||
| // only (hidden from the console) to aid debugging without adding CLI noise. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1147 +/- ##
==========================================
+ Coverage 82.90% 83.17% +0.27%
==========================================
Files 70 71 +1
Lines 15919 16040 +121
==========================================
+ Hits 13197 13342 +145
+ Misses 2722 2698 -24 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Introduce a typed api::message::QuarantineResolutionMode enum with a tolerant deserializer (unknown or absent values -> Unspecified) so a new server-side mode never breaks deserialization on older clients. It replaces the Option<String> previously threaded through the response, QuarantineContext, TestReport, and the quarantine disk cache, and collapses the two duplicated string-match sites into a single From impl. Also: - Cache the resolution mode in the disk-cache entry and restore it on a cache hit, so telemetry reports the true mode without a re-fetch. - Rework resolution-mode logging into human-readable messages, emitted at most once per report. - Drop the redundant standalone TestReport field (telemetry now reads from quarantine_config). - Populate quarantine_resolution_mode in the QuarantineContext test constructors the vendored-openssl build never compiled. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
max-trunk
marked this pull request as ready for review
July 24, 2026 20:42
… parse, cache key - BLOCKING: the traditional CLI path built getQuarantineConfig with test_collection_short_id always None. meta.base_props.test_collection isn't populated until upload_bundle (after the request is built), and only when the upload-intent response returns collection metadata, so the CLI value was silently dropped. Thread upload_args.test_collection_short_id (empty-filtered) into gather_exit_code_and_quarantined_tests_context and use it directly, matching the rspec path. - Include the collection id in the rspec disk-cache key so two runs in the same repo with different TRUNK_TEST_COLLECTION_ID values can't share an entry (and the wrong quarantine list). - Make QuarantineResolutionMode's deserializer tolerant of non-string JSON types (number/bool/object/null), not just unknown strings. - Filter empty TRUNK_TEST_COLLECTION_ID so an empty env var doesn't send "". - Collapse the duplicated resolution-mode log message into a QuarantineResolutionMode::resolution_log_line helper; mark cached lookups. - Inline the trivial quarantine_resolution_mode() mapping fn at its one call site; use the imported enum name consistently. - Tests: assert the collection id reaches the getQuarantineConfig request on the traditional path (cli/tests/upload.rs), plus a non-string deserialize case. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ests - Shorten the QuarantineResolutionMode doc comment; drop the deserializer and resolution_log_line comments in api/src/message.rs. - Remove the api/src/message.rs serde unit tests (type-only, low value). - Prune the per-variant and trailing comments on the proto QuarantineResolutionMode enum, keeping only the top-level line. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
dfrankland
approved these changes
Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Wires the CLI to the test-collection additions in the public API's
POST /metrics/getQuarantineConfigendpoint (server side: trunk-io/trunk#33132), across both the traditional and rspec invocation paths:--test-collection-idastestCollectionShortIdon the request.quarantineResolutionMode(repo|test_collection) in telemetry and logs the resolved source.The
--no-repoflag /noReporequest param are intentionally out of scope for this PR.Changes
api/src/message.rstest_collection_short_idtoGetQuarantineConfigRequest(testCollectionShortId, omitted whenNone).QuarantineResolutionModeenum (Repo|TestCollection|Unspecified) as thequarantine_resolution_modefield onGetQuarantineConfigResponse(#[serde(default)]). ItsDeserializeis tolerant: any unknown, absent, or non-string value degrades toUnspecifiedrather than failing the whole response parse, so a future server value never breaks older clients. A singleFrom<QuarantineResolutionMode>for the proto enum centralizes the mapping.--test-collection-idflag /TRUNK_TEST_COLLECTION_IDenv var, threaded into the request on the traditional path (cli/src/upload_command.rs→cli/src/context.rs) and read directly on the rspec path (test_report/src/report.rs). Empty values are filtered so an empty env var doesn't send"".QuarantineResolutionModeenum +UploadMetrics.quarantine_resolution_mode = 9inproto/proto/upload_metrics.proto; carried throughQuarantineContext(traditional) and a newRunUploadOptions.quarantine_resolution_mode_override(rspec).infolog names the resolved source (Resolved quarantine status for test collection <id>/... for repo <name>), emitted at most once per report (not per test); disk-cache hits are tagged(cached).Compatibility
GetQuarantineConfigResponsehas nodeny_unknown_fields, so the extra key is ignored; the server PR can land first.Unspecified.= 9) is skipped by servers that don't know it.Testing
cargo checkand the full test suite pass acrossapi,trunk-analytics-cli, andtest_report.cli/tests/upload.rsasserts that--test-collection-idreaches thegetQuarantineConfigrequest (guards the traditional-path wiring).Follow-up
--test-collection-id/ setsTRUNK_TEST_COLLECTION_ID(no Rust-side change needed).🤖 Generated with Claude Code