Fix full-only Surge promotion metadata#102
Merged
Merged
Conversation
Write a validated metadata sidecar next to full packages produced by surge pack, then have surge push use it to record the original full archive compression settings in releases.yml. This prevents full-only checkpoint releases from reaching storage with UNRECORDED encoding, which later made promotion unable to build channel-aware deltas. Validation: ./scripts/sync-surge-core-vendor.sh --check; ./scripts/check-version-sync.sh; cargo fmt --all -- --check; RUSTFLAGS="-D warnings" cargo test --workspace; cargo clippy --all-targets --all-features -- -D warnings; cargo clippy --workspace --lib --bins --examples -- -D warnings -D clippy::unwrap_used -D clippy::expect_used; cargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::pedantic; dotnet format dotnet/Surge.slnx --verify-no-changes; dotnet test dotnet/Surge.slnx --configuration Release
Contributor
Author
|
Local smoke test completed against the real Scenario:
Observed result:
|
There was a problem hiding this comment.
Pull request overview
This PR preserves full-archive encoding metadata across surge pack -> surge push -> surge promote by writing a validated metadata sidecar next to full packages and having surge push persist the original compression settings into releases.yml (while remaining compatible with older package directories that have no sidecar).
Changes:
- Write a
.metadata.ymlsidecar for each full package produced bysurge pack. - Teach
surge pushto load/validate the sidecar and recordfull_compression_level/full_zstd_workersinto the release index (fallback toUNRECORDEDwhen absent). - Add/extend CLI tests to verify metadata persistence and sidecar creation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| crates/surge-core/src/pack/builder.rs | Adds sidecar schema/constants + metadata struct and writes full-package metadata next to archives. |
| crates/surge-cli/src/commands/push.rs | Loads/validates sidecar metadata and records encoding settings into the release index; adds test coverage. |
| crates/surge-cli/src/commands/pack.rs | Extends pack tests to assert metadata sidecar contents are emitted. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
381
to
403
| /// Write built artifacts to `output_dir`. | ||
| pub fn write_artifacts_to(&self, output_dir: &Path) -> Result<Vec<PathBuf>> { | ||
| std::fs::create_dir_all(output_dir)?; | ||
|
|
||
| self.artifacts | ||
| let artifact_paths = self | ||
| .artifacts | ||
| .iter() | ||
| .map(|artifact| { | ||
| let path = output_dir.join(&artifact.filename); | ||
| write_file_atomic(&path, artifact.bytes())?; | ||
| Ok(path) | ||
| }) | ||
| .collect() | ||
| .collect::<Result<Vec<_>>>()?; | ||
|
|
||
| for artifact in self.artifacts.iter().filter(|artifact| !artifact.is_delta) { | ||
| let metadata = PackageArtifactMetadata::for_full_artifact(&self.app_id, &self.version, &self.rid, artifact); | ||
| let metadata_yaml = serde_yaml::to_string(&metadata)?; | ||
| let metadata_path = output_dir.join(package_metadata_filename(&artifact.filename)); | ||
| write_file_atomic(&metadata_path, metadata_yaml.as_bytes())?; | ||
| } | ||
|
|
||
| Ok(artifact_paths) | ||
| } |
| metadata_path.display() | ||
| ))); | ||
| } | ||
|
|
Comment on lines
+1113
to
+1123
| let full_filename = format!("{app_id}-{version}-{rid}-full.tar.zst"); | ||
| let metadata_path = packages_dir.join(package_metadata_filename(&full_filename)); | ||
| let metadata: PackageArtifactMetadata = | ||
| serde_yaml::from_slice(&std::fs::read(&metadata_path).expect("package metadata should be readable")) | ||
| .expect("package metadata should parse"); | ||
| assert_eq!(metadata.app_id, app_id); | ||
| assert_eq!(metadata.version, version); | ||
| assert_eq!(metadata.rid, rid); | ||
| assert_eq!(metadata.archive_filename, full_filename); | ||
| assert_eq!(metadata.full_compression_level, 3); | ||
| assert!(metadata.full_zstd_workers >= 0); |
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.
Summary
surge packsurge pushread that sidecar and persist the original full archive compression level/workers inreleases.ymlUNRECORDEDwhen no sidecar existsBehavior impact
Full-only checkpoint releases produced through
surge packand later published throughsurge pushnow keep enough encoding metadata forsurge promoteto build channel-aware deltas. This prevents the prior failure where a release with no primary delta andUNRECORDEDfull encoding could not be promoted from test to production.If a metadata sidecar exists but does not match the expected app, version, RID, archive filename, size, or SHA-256,
surge pushnow rejects it instead of recording stale encoding settings.Validation
./scripts/sync-surge-core-vendor.sh --check./scripts/check-version-sync.shcargo fmt --all -- --checkcargo test -p surge-cli execute_records_full_encoding_from_package_metadatacargo test -p surge-cli execute_pack_uses_default_dot_surge_artifacts_layoutRUSTFLAGS="-D warnings" cargo test --workspacecargo clippy --all-targets --all-features -- -D warningscargo clippy --workspace --lib --bins --examples -- -D warnings -D clippy::unwrap_used -D clippy::expect_usedcargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::pedanticdotnet format dotnet/Surge.slnx --verify-no-changesdotnet test dotnet/Surge.slnx --configuration ReleaseNotes
Agent-authored PR: squash-merge this PR.