feat(quarantine): persist quarantine resolution mode in meta.json - #1148
Conversation
|
😎 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. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1148 +/- ##
==========================================
+ Coverage 82.93% 83.21% +0.27%
==========================================
Files 71 71
Lines 16040 16044 +4
==========================================
+ Hits 13303 13351 +48
+ Misses 2737 2693 -44 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
5b5339d to
c060630
Compare
There was a problem hiding this comment.
this file's diff is just moving code to the bundle crate to avoid circular import
c060630 to
3f83df3
Compare
| impl QuarantineResolutionMode { | ||
| pub fn resolution_log_line( | ||
| &self, | ||
| test_collection_id: Option<&str>, | ||
| repo: &RepoUrlParts, | ||
| ) -> Option<String> { | ||
| match self { | ||
| Self::TestCollection => Some(format!( | ||
| "Resolved quarantine status for test collection {}", | ||
| test_collection_id.unwrap_or("unknown"), | ||
| )), | ||
| Self::Repo => Some(format!( | ||
| "Resolved quarantine status for repo {}", | ||
| repo.repo_full_name() | ||
| )), | ||
| Self::Unspecified => None, | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
I know this is just ported but optional note on copy:
Quarantine status applied from test collection {}
Quarantine status applied from repo {}
Resolved imo doesn't make much sense to the user since that's a bit internal to us
| } | ||
| } | ||
|
|
||
| impl QuarantineResolutionMode { |
There was a problem hiding this comment.
I love rust sometimes
The CLI already parses `quarantineResolutionMode` off the /metrics/getQuarantineConfig response (#1147), but only logs it and sends it as UploadMetrics telemetry — which cannot be tied back to a specific upload. Write it into meta.json so the services side can persist it per upload. Moves `QuarantineResolutionMode` from `api` into `bundle`: `BundleMetaBaseProps` cannot hold a type from `api` (which depends on `bundle`) without a dependency cycle, and consumers of the meta schema depend on `bundle`, `context`, and `proto` without `api`. `api::message` re-exports it, so existing call sites are untouched. The `From<_> for proto::…` impl moves with the enum — left behind it would violate the orphan rule. The field is `#[serde(default)]` on the shared base props rather than a new schema version: `parse_meta` tries V0_7_8 and falls back through six older structs that all flatten those same base props, so a non-defaulted field would fail every arm for bundles from older CLIs. There is no `deny_unknown_fields` anywhere, so an older reader ignores the new key. `run_upload` now resolves the mode before `upload_bundle` (which serializes meta.json into the tarball) and converts to the proto enum only at the telemetry site, so UploadMetrics stays byte-identical. The bindings' meta fixtures gain the new field: context-js round-trips a parsed bundle against its input fixture, and context-py's roundtrip test compares dumped JSON against an expected dict, so both see the newly serialized key. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
3f83df3 to
2739e5f
Compare
Why
#1147 taught the CLI to parse
quarantineResolutionModeoff the/metrics/getQuarantineConfigresponse — whether the server resolved quarantine status from the repo or the test collection. That value currently reaches only atracing::info!line andUploadMetricstelemetry, so it can't be tied back to a specific upload.Writing it into
meta.jsonlets the services side persist it per upload.The config fetch completes before
upload_bundleserializesmeta.jsoninto the tarball, so the value can ride along in the bundle rather than on thecreateBundleUploadrequest.What
QuarantineResolutionModefromapiintobundle(newbundle/src/quarantine_resolution_mode.rs).BundleMetaBasePropscan't hold anapitype —apidepends onbundle, so that's a cycle — and consumers of the meta schema depend onbundle/context/protowithoutapi.api::messagere-exports it, so existing call sites are untouched; theFrom<_> for proto::…impl moves with the enum, since leaving it behind violates the orphan rule.#[serde(default)] quarantine_resolution_modetoBundleMetaBaseProps.run_uploadresolves the mode beforeupload_bundleand converts to the proto enum only at the telemetry site, soUploadMetricsstays byte-identical.quarantine_resolution_mode_for_telemetryreturns the bundle-level enum and drops its now-inaccurate suffix, since it feedsmeta.jsontoo.Why no new
BundleMetaV0_7_9#[serde(default)]on the shared base props is load-bearing:parse_metatriesV0_7_8and falls back through six older structs that all flatten these same props, so a non-defaulted field fails every arm for bundles from older CLIs. Precedent is one line up —test_collectionis a#[serde(flatten, default)]addition to the same struct. A new variant would cost aVersionedBundlearm plus a downgrade impl per version and buy nothing:cli_versionalready distinguishes a pre-field CLI from a genuineUnspecified. There's nodeny_unknown_fieldsanywhere, so older readers ignore the new key.Testing
cli/tests/upload.rsasserts atest_collectionresponse reaches the extractedmeta.jsonand that telemetry still carries the same value.wasm-pack build,maturin develop):context-jscompares a parsed bundle against its input fixture. Without the fixture field, 6 tests fail — a runtime deep-equality diff, not a type error, since tsify renders the field optional because of#[serde(default)]. 28/28 pass.context-py's roundtrip test compares dumped JSON against an expected dict, so the defaulted key goes on the expected side (mirroringtest_collection_id). 35/35 pass.test_report/tests/publish.rsfails exactly one ofpublish_environment_variable_overrides/publish_variant_priority_constructor_over_envper run, and which one varies between runs — reproduced on unmodifiedmain.🤖 Generated with Claude Code