team-ljyzipelo

공개

GZip 파일 작업 연결 회귀 시험을 추가함

작성자
코노모리 카논
작성 시각
커밋
287aaeb93f7e362d3b87354e8e372fcdd3ade146
부모
4c6ae4b
이 시점의 파일 보기

변경된 파일 17개

+2,413-0
추가tests/rust-gzip-file-job/Cargo.lock+132-0
@@ -0,0 +1,132 @@
1추가: # This file is automatically @generated by Cargo.
2추가: # It is not intended for manual editing.
3추가: version = 4
4추가:
5추가: [[package]]
6추가: name = "block-buffer"
7추가: version = "0.10.4"
8추가: source = "registry+https://github.com/rust-lang/crates.io-index"
9추가: checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
10추가: dependencies = [
11추가: "generic-array",
12추가: ]
13추가:
14추가: [[package]]
15추가: name = "cfg-if"
16추가: version = "1.0.5"
17추가: source = "registry+https://github.com/rust-lang/crates.io-index"
18추가: checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
19추가:
20추가: [[package]]
21추가: name = "cpufeatures"
22추가: version = "0.2.17"
23추가: source = "registry+https://github.com/rust-lang/crates.io-index"
24추가: checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
25추가: dependencies = [
26추가: "libc",
27추가: ]
28추가:
29추가: [[package]]
30추가: name = "crypto-common"
31추가: version = "0.1.7"
32추가: source = "registry+https://github.com/rust-lang/crates.io-index"
33추가: checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
34추가: dependencies = [
35추가: "generic-array",
36추가: "typenum",
37추가: ]
38추가:
39추가: [[package]]
40추가: name = "digest"
41추가: version = "0.10.7"
42추가: source = "registry+https://github.com/rust-lang/crates.io-index"
43추가: checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
44추가: dependencies = [
45추가: "block-buffer",
46추가: "crypto-common",
47추가: ]
48추가:
49추가: [[package]]
50추가: name = "generic-array"
51추가: version = "0.14.7"
52추가: source = "registry+https://github.com/rust-lang/crates.io-index"
53추가: checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
54추가: dependencies = [
55추가: "typenum",
56추가: "version_check",
57추가: ]
58추가:
59추가: [[package]]
60추가: name = "libc"
61추가: version = "0.2.191"
62추가: source = "registry+https://github.com/rust-lang/crates.io-index"
63추가: checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
64추가:
65추가: [[package]]
66추가: name = "sha2"
67추가: version = "0.10.9"
68추가: source = "registry+https://github.com/rust-lang/crates.io-index"
69추가: checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
70추가: dependencies = [
71추가: "cfg-if",
72추가: "cpufeatures",
73추가: "digest",
74추가: ]
75추가:
76추가: [[package]]
77추가: name = "typenum"
78추가: version = "1.20.1"
79추가: source = "registry+https://github.com/rust-lang/crates.io-index"
80추가: checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
81추가:
82추가: [[package]]
83추가: name = "version_check"
84추가: version = "0.9.5"
85추가: source = "registry+https://github.com/rust-lang/crates.io-index"
86추가: checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
87추가:
88추가: [[package]]
89추가: name = "zipelo-file-publication"
90추가: version = "0.1.0"
91추가: dependencies = [
92추가: "libc",
93추가: ]
94추가:
95추가: [[package]]
96추가: name = "zipelo-file-snapshot"
97추가: version = "0.1.0"
98추가: dependencies = [
99추가: "libc",
100추가: "sha2",
101추가: ]
102추가:
103추가: [[package]]
104추가: name = "zipelo-gzip-file-job"
105추가: version = "0.1.0"
106추가: dependencies = [
107추가: "zipelo-file-publication",
108추가: "zipelo-file-snapshot",
109추가: "zipelo-memory-gzip-reader",
110추가: ]
111추가:
112추가: [[package]]
113추가: name = "zipelo-gzip-file-job-regressions"
114추가: version = "0.1.0"
115추가: dependencies = [
116추가: "libc",
117추가: "sha2",
118추가: "zipelo-gzip-file-job",
119추가: ]
120추가:
121추가: [[package]]
122추가: name = "zipelo-memory-gzip-reader"
123추가: version = "0.1.0"
124추가: dependencies = [
125추가: "zlib-rs",
126추가: ]
127추가:
128추가: [[package]]
129추가: name = "zlib-rs"
130추가: version = "0.6.8"
131추가: source = "registry+https://github.com/rust-lang/crates.io-index"
132추가: checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112"
추가tests/rust-gzip-file-job/Cargo.toml+21-0
@@ -0,0 +1,21 @@
1추가: [package]
2추가: name = "zipelo-gzip-file-job-regressions"
3추가: version = "0.1.0"
4추가: edition = "2024"
5추가: rust-version = "1.99"
6추가: license = "MIT"
7추가: publish = false
8추가: autotests = false
9추가: autoexamples = false
10추가: autobenches = false
11추가:
12추가: [[test]]
13추가: name = "file_job_public_api"
14추가: path = "main.rs"
15추가:
16추가: [dependencies]
17추가: job = { package = "zipelo-gzip-file-job", path = "../../experiments/rust-gzip-file-job" }
18추가: libc = { version = "=0.2.191", default-features = false, features = ["std"] }
19추가: sha2 = { version = "=0.10.9", default-features = false, features = ["std", "force-soft"] }
20추가:
21추가: [workspace]
추가tests/rust-gzip-file-job/SHA256SUMS+16-0
@@ -0,0 +1,16 @@
1추가: e291067ef69ee6b11deb7c03e0a961609f456ff3185563aa7d2d0c31cf3e8936 Cargo.lock
2추가: 90bc3eb6c50d661df2d6b88a7a89a6a46aee61d3f082e6910638a4c7fb6cced5 Cargo.toml
3추가: 543ac298aec6727618d3e161261da91e2ddd04bd136583f2aa640a71bec4deda concurrency.rs
4추가: 9807046c32796e11ac670c5f7c153b8e6c6c8cd20b75bde8aeea46e7842ac185 contract.json
5추가: c5bb942083045c9f16394be31bbc36117cc1d0fae04745a9e05dfcf06ba548fd control.rs
6추가: b7eef4ba661501b2da6b87994509cbc398b5c1095112e2609a8275fcc814374c fixtures.rs
7추가: 609cefa6e310a8da08c4a97fec9b7d59904e096d5754bd9845669f8815a285ac invalid.rs
8추가: aae6c696bd85e5e173b51f27df310e78c4a6a7340649cba7f01035aa0a6c948a limits.rs
9추가: eadaf17070d3b5344f07f83c1d62782f56f267c4e458acd9f1525274efa3dcca main.rs
10추가: f3507dc9f91af604c779ad30f46c59b69a6e0b45eb354fcceee724987d2231a0 namespace.rs
11추가: 3f04482a9f9cbe3dc37be183dd6ace67d30ee680447e773321e73b97034420d0 run-plan.json
12추가: 40403433dea41d9ff685aff2e0391af1515272771243be03d485b2f2b40857d2 source-pins.json
13추가: b88bd70cef787a0a5397de363dfb09bb5aa7610ba698c8c2f836a718b3ff6114 static_check.py
14추가: 53a7bc6d4cadf3c69c13440d79288b424e9ac1f1873984fba550e7b78664a3f6 static_check_helper_tests.py
15추가: ff7f8d2f4b178eab74faa40d70a55c51b84da504eaa087f17ab310fdc9560e45 success.rs
16추가: 7879f24248beba8694504c276dc24d15a33dd7d491f7edf168ea20a6b41c9f60 support.rs
추가tests/rust-gzip-file-job/concurrency.rs+134-0
@@ -0,0 +1,134 @@
1추가: use crate::{fixtures::*, support::*};
2추가: use job::{Event, FileJob, Limits, Outcome, Stop, publication};
3추가: use std::{sync::mpsc, thread, time::Duration};
4추가:
5추가: const WAIT: Duration = Duration::from_secs(5);
6추가:
7추가: #[test]
8추가: fn two_file_jobs_for_one_name_have_one_complete_winner() {
9추가: let sandbox = Sandbox::new();
10추가: let parent = sandbox.parent();
11추가: let (ready_tx, ready_rx) = mpsc::sync_channel(2);
12추가: let (done_tx, done_rx) = mpsc::sync_channel(2);
13추가: let mut releases = Vec::new();
14추가: let mut handles = Vec::new();
15추가: let mut inputs = Vec::new();
16추가: for marker in [65_u8, 66_u8] {
17추가: let archive = stored(&vec![marker; 65_537]);
18추가: let input = sandbox.file(format!("input-{marker}.gz"), &archive);
19추가: inputs.push((input.clone(), identity(&input), archive));
20추가: let (release_tx, release_rx) = mpsc::sync_channel(1);
21추가: releases.push(release_tx);
22추가: let ready = ready_tx.clone();
23추가: let done = done_tx.clone();
24추가: let parent = parent.clone();
25추가: handles.push(thread::spawn(move || {
26추가: let (task, cancel) = FileJob::new();
27추가: let mut trace = Trace::default();
28추가: let report = task.run(request(&input, &parent, Limits::default()), |point| {
29추가: trace.push(point);
30추가: if matches!(point.event, Event::Publication(native) if native.stage == publication::Stage::BeforeCommit) {
31추가: ready.send(marker).unwrap();
32추가: release_rx.recv_timeout(WAIT).expect("게시 해제 신호 시간 초과");
33추가: }
34추가: Ok::<_, Stop<()>>(())
35추가: });
36추가: trace.finish(&report);
37추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished);
38추가: assert!(done.send((marker, report)).is_ok());
39추가: }));
40추가: }
41추가: drop(ready_tx);
42추가: drop(done_tx);
43추가: let mut ready = vec![
44추가: ready_rx.recv_timeout(WAIT).unwrap(),
45추가: ready_rx.recv_timeout(WAIT).unwrap(),
46추가: ];
47추가: ready.sort();
48추가: assert_eq!(ready, [65, 66]);
49추가: assert!(names(&parent).is_empty());
50추가: for release in releases {
51추가: release.send(()).unwrap();
52추가: }
53추가: let results = [
54추가: done_rx.recv_timeout(WAIT).unwrap(),
55추가: done_rx.recv_timeout(WAIT).unwrap(),
56추가: ];
57추가: for handle in handles {
58추가: handle.join().expect("파일 작업 스레드 실패");
59추가: }
60추가: assert_eq!(results.iter().filter(|(_, report)| matches!(
61추가: &report.outcome, Outcome::Publication(native) if matches!(&native.outcome, publication::Outcome::Committed { .. })
62추가: )).count(), 1);
63추가: for (marker, report) in results {
64추가: let (_, before, archive) = &inputs[(marker - 65) as usize];
65추가: observations(
66추가: &report,
67추가: (before.0, before.1),
68추가: archive,
69추가: &vec![marker; 65_537],
70추가: 10,
71추가: );
72추가: if matches!(&report.outcome, Outcome::Publication(native) if matches!(&native.outcome, publication::Outcome::Committed { .. }))
73추가: {
74추가: committed(&report, &parent, &vec![marker; 65_537]);
75추가: } else {
76추가: conflict(&report, 65_537);
77추가: }
78추가: }
79추가: for (input, before, archive) in inputs {
80추가: assert_eq!(identity(&input), before);
81추가: assert_eq!(std::fs::read(input).unwrap(), archive);
82추가: }
83추가: sandbox.finish();
84추가: }
85추가:
86추가: #[test]
87추가: fn acknowledged_external_cancel_before_commit_prevents_publication() {
88추가: let sandbox = Sandbox::new();
89추가: let input = sandbox.file("input.gz", &stored(b"abc"));
90추가: let parent = sandbox.parent();
91추가: let worker_parent = parent.clone();
92추가: let (task, cancel) = FileJob::new();
93추가: let (ready_tx, ready_rx) = mpsc::sync_channel(1);
94추가: let (release_tx, release_rx) = mpsc::sync_channel(1);
95추가: let (done_tx, done_rx) = mpsc::sync_channel(1);
96추가: let handle = thread::spawn(move || {
97추가: let mut trace = Trace::default();
98추가: let report = task.run(request(&input, &worker_parent, Limits::default()), |point| {
99추가: trace.push(point);
100추가: if matches!(point.event, Event::Publication(native) if native.stage == publication::Stage::BeforeCommit) {
101추가: ready_tx.send(()).unwrap();
102추가: release_rx.recv_timeout(WAIT).expect("취소 확인 신호 시간 초과");
103추가: }
104추가: Ok::<_, Stop<()>>(())
105추가: });
106추가: trace.finish(&report);
107추가: assert!(done_tx.send(report).is_ok());
108추가: });
109추가: ready_rx.recv_timeout(WAIT).unwrap();
110추가: assert_eq!(cancel.request(), publication::CancelDecision::Requested);
111추가: assert_eq!(
112추가: cancel.clone().request(),
113추가: publication::CancelDecision::AlreadyRequested
114추가: );
115추가: release_tx.send(()).unwrap();
116추가: let report = done_rx.recv_timeout(WAIT).unwrap();
117추가: handle.join().expect("취소 스레드 실패");
118추가: match &report.outcome {
119추가: Outcome::Publication(native) => {
120추가: assert!(matches!(
121추가: native.outcome,
122추가: publication::Outcome::NotCommitted(publication::Error::Cancelled)
123추가: ));
124추가: assert_eq!(native.usage.link_calls, 0);
125추가: assert_eq!(native.usage.actual_written_bytes, 3);
126추가: assert_eq!(native.usage.actual_read_bytes, 3);
127추가: cleanup(&native.cleanup, 4);
128추가: }
129추가: _ => panic!("게시 전 취소가 보존되지 않음"),
130추가: }
131추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished);
132추가: assert!(names(&parent).is_empty());
133추가: sandbox.finish();
134추가: }
추가tests/rust-gzip-file-job/contract.json+190-0
@@ -0,0 +1,190 @@
1추가: {
2추가: "schema": "zipelo.gzip-file-job-regressions.v1",
3추가: "source_head": "4c6ae4b3a7ab12a992598e94e7b02f3a167fbbd4",
4추가: "source_tree": "9a01a37623b163c35ca4ff25963b2e11c61a0c35",
5추가: "source_manifest_sha256": "ef32ad5306d2d98751836846f631f66c562e4b55caf5d3422e120305aa78b37f",
6추가: "branch": "features/rust-gzip-file-job-regressions",
7추가: "stage": "Source/static only. Rust compilation, discovery and execution have not been performed.",
8추가: "scope": "New root tests only; frozen FileJob and native snapshot/GZip/publication sources, lockfiles and private receipt constructors remain unchanged.",
9추가: "declared_test_count": 62,
10추가: "test_names": [
11추가: "concurrency::acknowledged_external_cancel_before_commit_prevents_publication",
12추가: "concurrency::two_file_jobs_for_one_name_have_one_complete_winner",
13추가: "control::cancel_decode_after_inflate",
14추가: "control::cancel_decode_after_output",
15추가: "control::cancel_decode_before_inflate",
16추가: "control::cancel_decode_before_return",
17추가: "control::cancel_decode_header",
18추가: "control::cancel_decode_start",
19추가: "control::cancel_decode_trailer",
20추가: "control::cancel_publication_before_commit",
21추가: "control::cancel_publication_opening",
22추가: "control::cancel_publication_verifying",
23추가: "control::cancel_publication_writing",
24추가: "control::cancel_snapshot_comparing",
25추가: "control::cancel_snapshot_copying",
26추가: "control::cancel_snapshot_finalizing",
27추가: "control::cancel_snapshot_opening",
28추가: "control::cancel_snapshot_pinned",
29추가: "control::cancellation_after_return_preserves_committed_bytes",
30추가: "control::decode_observer_error_beats_accepted_cancel",
31추가: "control::dropping_unused_job_finishes_its_gate",
32추가: "control::local_decode_stop_does_not_need_cancel_request",
33추가: "control::local_publication_stop_does_not_need_cancel_request",
34추가: "control::local_snapshot_stop_does_not_need_cancel_request",
35추가: "control::pre_cancel_stops_before_snapshot_open",
36추가: "control::publication_observer_error_beats_accepted_cancel",
37추가: "control::snapshot_observer_error_beats_accepted_cancel",
38추가: "invalid::bad_crc_prevents_publication",
39추가: "invalid::bad_size_prevents_publication",
40추가: "invalid::concatenated_members_prevent_publication",
41추가: "invalid::invalid_deflate_preserves_backend_error",
42추가: "invalid::invalid_magic_prevents_publication",
43추가: "invalid::trailing_byte_prevents_publication",
44추가: "invalid::truncated_trailer_prevents_publication",
45추가: "limits::exact_limits_in_all_stages_allow_commit",
46추가: "limits::gzip_input_limit_stops_after_snapshot",
47추가: "limits::gzip_metadata_limit_preserves_header_cost",
48추가: "limits::gzip_processed_failure_includes_post_checkpoint_charge",
49추가: "limits::gzip_selected_output_limit_preserves_consumed_cost",
50추가: "limits::invalid_decode_duration_retains_snapshot_cost",
51추가: "limits::invalid_publication_duration_retains_both_prior_costs",
52추가: "limits::invalid_snapshot_duration_has_zero_cost",
53추가: "limits::publication_byte_limit_preserves_completed_prior_stages",
54추가: "limits::publication_call_limit_retains_pre_eof_usage",
55추가: "limits::publication_io_limit_retains_pre_eof_usage",
56추가: "limits::snapshot_byte_limit_preserves_partial_usage",
57추가: "limits::snapshot_call_limit_retains_last_eof_reservation_boundary",
58추가: "limits::snapshot_io_limit_retains_last_eof_reservation_boundary",
59추가: "namespace::existing_directory_and_child_survive_conflict",
60추가: "namespace::existing_file_bytes_and_identity_survive_conflict",
61추가: "namespace::existing_symlink_and_target_survive_conflict",
62추가: "namespace::identical_input_and_output_name_preserves_archive",
63추가: "namespace::missing_owned_input_preserves_native_open_error",
64추가: "namespace::replaced_parent_path_does_not_redirect_pinned_commit",
65추가: "success::chunk_minus_one_output",
66추가: "success::chunk_output",
67추가: "success::chunk_plus_one_output",
68추가: "success::empty_output",
69추가: "success::header_name_and_comment_never_select_destination",
70추가: "success::known_bytes_output",
71추가: "success::one_byte_output",
72추가: "success::replacing_input_after_snapshot_uses_captured_owned_bytes"
73추가: ],
74추가: "evidence_classes": {
75추가: "concurrency::acknowledged_external_cancel_before_commit_prevents_publication": "actual-file-job-with-controlled-callback-or-schedule",
76추가: "concurrency::two_file_jobs_for_one_name_have_one_complete_winner": "actual-file-job-with-controlled-callback-or-schedule",
77추가: "control::cancel_decode_after_inflate": "actual-file-job-with-controlled-callback-or-schedule",
78추가: "control::cancel_decode_after_output": "actual-file-job-with-controlled-callback-or-schedule",
79추가: "control::cancel_decode_before_inflate": "actual-file-job-with-controlled-callback-or-schedule",
80추가: "control::cancel_decode_before_return": "actual-file-job-with-controlled-callback-or-schedule",
81추가: "control::cancel_decode_header": "actual-file-job-with-controlled-callback-or-schedule",
82추가: "control::cancel_decode_start": "actual-file-job-with-controlled-callback-or-schedule",
83추가: "control::cancel_decode_trailer": "actual-file-job-with-controlled-callback-or-schedule",
84추가: "control::cancel_publication_before_commit": "actual-file-job-with-controlled-callback-or-schedule",
85추가: "control::cancel_publication_opening": "actual-file-job-with-controlled-callback-or-schedule",
86추가: "control::cancel_publication_verifying": "actual-file-job-with-controlled-callback-or-schedule",
87추가: "control::cancel_publication_writing": "actual-file-job-with-controlled-callback-or-schedule",
88추가: "control::cancel_snapshot_comparing": "actual-file-job-with-controlled-callback-or-schedule",
89추가: "control::cancel_snapshot_copying": "actual-file-job-with-controlled-callback-or-schedule",
90추가: "control::cancel_snapshot_finalizing": "actual-file-job-with-controlled-callback-or-schedule",
91추가: "control::cancel_snapshot_opening": "actual-file-job-with-controlled-callback-or-schedule",
92추가: "control::cancel_snapshot_pinned": "actual-file-job-with-controlled-callback-or-schedule",
93추가: "control::cancellation_after_return_preserves_committed_bytes": "actual-file-job-with-controlled-callback-or-schedule",
94추가: "control::decode_observer_error_beats_accepted_cancel": "actual-file-job-with-controlled-callback-or-schedule",
95추가: "control::dropping_unused_job_finishes_its_gate": "gate-lifecycle-only",
96추가: "control::local_decode_stop_does_not_need_cancel_request": "actual-file-job-with-controlled-callback-or-schedule",
97추가: "control::local_publication_stop_does_not_need_cancel_request": "actual-file-job-with-controlled-callback-or-schedule",
98추가: "control::local_snapshot_stop_does_not_need_cancel_request": "actual-file-job-with-controlled-callback-or-schedule",
99추가: "control::pre_cancel_stops_before_snapshot_open": "actual-file-job-with-controlled-callback-or-schedule",
100추가: "control::publication_observer_error_beats_accepted_cancel": "actual-file-job-with-controlled-callback-or-schedule",
101추가: "control::snapshot_observer_error_beats_accepted_cancel": "actual-file-job-with-controlled-callback-or-schedule",
102추가: "invalid::bad_crc_prevents_publication": "actual-file-job",
103추가: "invalid::bad_size_prevents_publication": "actual-file-job",
104추가: "invalid::concatenated_members_prevent_publication": "actual-file-job",
105추가: "invalid::invalid_deflate_preserves_backend_error": "actual-file-job",
106추가: "invalid::invalid_magic_prevents_publication": "actual-file-job",
107추가: "invalid::trailing_byte_prevents_publication": "actual-file-job",
108추가: "invalid::truncated_trailer_prevents_publication": "actual-file-job",
109추가: "limits::exact_limits_in_all_stages_allow_commit": "actual-file-job",
110추가: "limits::gzip_input_limit_stops_after_snapshot": "actual-file-job",
111추가: "limits::gzip_metadata_limit_preserves_header_cost": "actual-file-job",
112추가: "limits::gzip_processed_failure_includes_post_checkpoint_charge": "actual-file-job",
113추가: "limits::gzip_selected_output_limit_preserves_consumed_cost": "actual-file-job",
114추가: "limits::invalid_decode_duration_retains_snapshot_cost": "actual-file-job",
115추가: "limits::invalid_publication_duration_retains_both_prior_costs": "actual-file-job",
116추가: "limits::invalid_snapshot_duration_has_zero_cost": "actual-file-job",
117추가: "limits::publication_byte_limit_preserves_completed_prior_stages": "actual-file-job",
118추가: "limits::publication_call_limit_retains_pre_eof_usage": "actual-file-job",
119추가: "limits::publication_io_limit_retains_pre_eof_usage": "actual-file-job",
120추가: "limits::snapshot_byte_limit_preserves_partial_usage": "actual-file-job",
121추가: "limits::snapshot_call_limit_retains_last_eof_reservation_boundary": "actual-file-job",
122추가: "limits::snapshot_io_limit_retains_last_eof_reservation_boundary": "actual-file-job",
123추가: "namespace::existing_directory_and_child_survive_conflict": "actual-file-job",
124추가: "namespace::existing_file_bytes_and_identity_survive_conflict": "actual-file-job",
125추가: "namespace::existing_symlink_and_target_survive_conflict": "actual-file-job",
126추가: "namespace::identical_input_and_output_name_preserves_archive": "actual-file-job",
127추가: "namespace::missing_owned_input_preserves_native_open_error": "actual-file-job",
128추가: "namespace::replaced_parent_path_does_not_redirect_pinned_commit": "actual-file-job-with-controlled-callback-or-schedule",
129추가: "success::chunk_minus_one_output": "actual-file-job",
130추가: "success::chunk_output": "actual-file-job",
131추가: "success::chunk_plus_one_output": "actual-file-job",
132추가: "success::empty_output": "actual-file-job",
133추가: "success::header_name_and_comment_never_select_destination": "actual-file-job",
134추가: "success::known_bytes_output": "actual-file-job",
135추가: "success::one_byte_output": "actual-file-job",
136추가: "success::replacing_input_after_snapshot_uses_captured_owned_bytes": "actual-file-job-with-controlled-callback-or-schedule"
137추가: },
138추가: "entrypoint": "61 cases exercise original FileJob::run with owned synthetic inputs. The two-job race calls it twice; one separate unused-job Drop case covers gate lifecycle only. No fake native reports or copied production implementation.",
139추가: "fixtures": "Small in-memory GZip generator uses uncompressed DEFLATE blocks <=65535 and bitwise CRC32. Original content <=65537 bytes, header strings synthetic. No repository/user archive input, shell/network/process launcher or host font access.",
140추가: "coverage": {
141추가: "normal": "Empty/one/known bytes and 65535/65536/65537 outputs; actual published bytes, observed input identity/SHA256, GZip boundary/CRC, file receipt identity, native durability, close results and namespace.",
142추가: "ownership": "Replace owned input pathname only at Decode::Start after snapshot completed. Output still comes from old captured bytes; replacement and saved original remain intact until assertions finish. Header FNAME/FCOMMENT are not destinations.",
143추가: "invalid": "Bad magic, invalid DEFLATE, CRC/ISIZE mismatch, concatenated member, trailing byte and truncated trailer retain typed error class; publication events/Usage remain zero and output absent.",
144추가: "usage": "Exact small-input budgets and one-less snapshot bytes/I/O/read calls, GZip input/processed/output/metadata and publication bytes/I/O/calls. Invalid zero durations at each stage. Compare final counters including post-checkpoint decode charge; no sums across incompatible units.",
145추가: "observer": "Rc pointer-identical non-Send callback errors at snapshot Finalizing, decode AfterOutput and publication BeforeCommit survive an overlapping accepted cancellation. Later stage events/output forbidden.",
146추가: "cancellation": "Pre-request idempotence; first checkpoint at all 5 snapshot, 7 decoder and 4 publication stages; local Stop::Cancelled at each phase; external acknowledged BeforeCommit cancellation; Finished after return preserves committed bytes.",
147추가: "namespace": "Existing file/directory/symlink and input==output retain bytes/identity; owned parent rename at BeforeCommit still commits to pinned old parent. Two prepared FileJobs compete for one name with exactly one full winner and one typed EEXIST.",
148추가: "cleanup": "No Drop cleanup for Sandbox. Assertions and bounded thread completion precede explicit finish; failed files stay for diagnosis. Check owned open descriptors before removing only identity-matched private case root.",
149추가: "reports": "Actual NotCommitted/Committed exercised with native Cleanup and durability. CommitUncertain, failed sync/close are not fabricated as execution evidence."
150추가: },
151추가: "unverified": [
152추가: "Rust type checking, compilation, discovery and runtime of these new tests are deferred until fixed head review.",
153추가: "TooLate CAS-to-link window has no deterministic barrier. Finished after return is not TooLate coverage.",
154추가: "Non-EEXIST linkat/CommitUncertain, file or parent fsync failures, close failures, partial/zero writes, read/seek errors, allocation failures and adverse filesystem faults are not deterministically injected.",
155추가: "MissingSelectedOutput and SelectedLengthMismatch cannot be produced by the normal decoder API. No private receipt construction or syscall interposition.",
156추가: "Real elapsed deadline expiry, hostile concurrent input ABA, crash durability, physical deletion and hard resource interruption are unverified.",
157추가: "OS worker isolation, product Published, UI integration, Windows, Ubuntu24 native platform and folder extraction are outside this suite.",
158추가: "Prior PR51 54 passes are native publication evidence only and are not counted as FileJob executions."
159추가: ],
160추가: "minimum_seams": "Only if separately requested: test-only syscall-result injection and post-CAS barrier owned by backend, plus private selected-output validation helper. No public receipt constructor; no production modification in this candidate.",
161추가: "review": "Fixed control flow preserves snapshot failure usage, final GZip Budget even after last checkpoint, original publication report and accepted cancellation gate. No confirmed source defect from read-only review; static review is not runtime proof.",
162추가: "dependencies": {
163추가: "new_registry_versions": 0,
164추가: "direct_existing": [
165추가: "libc =0.2.191 std",
166추가: "sha2 =0.10.9 std force-soft"
167추가: ],
168추가: "path": "../../experiments/rust-gzip-file-job",
169추가: "expected_registry_packages": 11
170추가: },
171추가: "deliverables": [
172추가: "Cargo.toml",
173추가: "Cargo.lock",
174추가: "main.rs",
175추가: "support.rs",
176추가: "fixtures.rs",
177추가: "success.rs",
178추가: "invalid.rs",
179추가: "limits.rs",
180추가: "control.rs",
181추가: "namespace.rs",
182추가: "concurrency.rs",
183추가: "source-pins.json",
184추가: "contract.json",
185추가: "run-plan.json",
186추가: "static_check.py",
187추가: "static_check_helper_tests.py",
188추가: "SHA256SUMS"
189추가: ]
190추가: }
추가tests/rust-gzip-file-job/control.rs+287-0
@@ -0,0 +1,287 @@
1추가: use crate::{fixtures::*, support::*};
2추가: use job::{Event, FileJob, Limits, Outcome, Report, Stop, gzip, publication, snapshot};
3추가: use std::{fs, rc::Rc};
4추가:
5추가: #[derive(Clone, Copy)]
6추가: enum Target {
7추가: Snapshot(snapshot::Stage),
8추가: Decode(gzip::Stage),
9추가: Publication(publication::Stage),
10추가: }
11추가:
12추가: impl Target {
13추가: fn matches(self, event: Event) -> bool {
14추가: match (self, event) {
15추가: (Self::Snapshot(stage), Event::Snapshot(point)) => stage == point.stage,
16추가: (Self::Decode(stage), Event::Decode(point)) => stage == point.stage,
17추가: (Self::Publication(stage), Event::Publication(point)) => stage == point.stage,
18추가: _ => false,
19추가: }
20추가: }
21추가: }
22추가:
23추가: fn cancelled(report: &Report<()>, target: Target) {
24추가: match (&report.outcome, target) {
25추가: (Outcome::SnapshotFailed(failure), Target::Snapshot(_)) => {
26추가: assert!(matches!(failure.cause, snapshot::Error::Cancelled))
27추가: }
28추가: (
29추가: Outcome::DecodeFailed(gzip::Error::Reader(gzip::Failure::Cancelled)),
30추가: Target::Decode(_),
31추가: ) => {}
32추가: (Outcome::Publication(native), Target::Publication(stage)) => {
33추가: assert!(matches!(
34추가: native.outcome,
35추가: publication::Outcome::NotCommitted(publication::Error::Cancelled)
36추가: ));
37추가: assert_eq!(native.usage.link_calls, 0);
38추가: cleanup(
39추가: &native.cleanup,
40추가: match stage {
41추가: publication::Stage::Opening => 0,
42추가: publication::Stage::BeforeCommit => 4,
43추가: _ => 2,
44추가: },
45추가: );
46추가: }
47추가: _ => panic!("취소 원인이 해당 단계에 보존되지 않음"),
48추가: }
49추가: }
50추가:
51추가: fn cancel_at(target: Target, local_stop: bool) {
52추가: let sandbox = Sandbox::new();
53추가: let archive = stored(b"abc");
54추가: let input = sandbox.file("input.gz", &archive);
55추가: let before = identity(&input);
56추가: let parent = sandbox.parent();
57추가: let (task, cancel) = FileJob::new();
58추가: let mut trace = Trace::default();
59추가: let mut reached = false;
60추가: let report = task.run(request(&input, &parent, Limits::default()), |point| {
61추가: trace.push(point);
62추가: if target.matches(point.event) {
63추가: reached = true;
64추가: if local_stop {
65추가: return Err(Stop::<()>::Cancelled);
66추가: }
67추가: assert_eq!(cancel.request(), publication::CancelDecision::Requested);
68추가: assert_eq!(
69추가: cancel.clone().request(),
70추가: publication::CancelDecision::AlreadyRequested
71추가: );
72추가: }
73추가: Ok(())
74추가: });
75추가: assert!(reached);
76추가: trace.finish(&report);
77추가: assert!(target.matches(trace.points.last().unwrap().event));
78추가: assert_eq!(report.usage, trace.points.last().unwrap().usage);
79추가: cancelled(&report, target);
80추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished);
81추가: assert!(names(&parent).is_empty());
82추가: assert_eq!(identity(&input), before);
83추가: sandbox.finish();
84추가: }
85추가:
86추가: #[test]
87추가: fn pre_cancel_stops_before_snapshot_open() {
88추가: let sandbox = Sandbox::new();
89추가: let input = sandbox.file("input.gz", &stored(b"abc"));
90추가: let (task, cancel) = FileJob::new();
91추가: assert_eq!(cancel.request(), publication::CancelDecision::Requested);
92추가: assert_eq!(
93추가: cancel.clone().request(),
94추가: publication::CancelDecision::AlreadyRequested
95추가: );
96추가: let mut trace = Trace::default();
97추가: let report = task.run(
98추가: request(&input, &sandbox.parent(), Limits::default()),
99추가: |point| {
100추가: trace.push(point);
101추가: Ok::<_, Stop<()>>(())
102추가: },
103추가: );
104추가: trace.finish(&report);
105추가: assert_eq!(trace.points.len(), 1);
106추가: assert_eq!(report.usage, job::Usage::default());
107추가: cancelled(&report, Target::Snapshot(snapshot::Stage::Opening));
108추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished);
109추가: assert!(names(&sandbox.parent()).is_empty());
110추가: sandbox.finish();
111추가: }
112추가:
113추가: fn observer_error(target: Target) {
114추가: let sandbox = Sandbox::new();
115추가: let input = sandbox.file("input.gz", &stored(b"abc"));
116추가: let parent = sandbox.parent();
117추가: let marker = Rc::new(String::from("원래 observer 오류"));
118추가: let (task, cancel) = FileJob::new();
119추가: let mut trace = Trace::default();
120추가: let report = task.run(request(&input, &parent, Limits::default()), |point| {
121추가: trace.push(point);
122추가: if target.matches(point.event) {
123추가: assert_eq!(cancel.request(), publication::CancelDecision::Requested);
124추가: Err(Stop::Callback(marker.clone()))
125추가: } else {
126추가: Ok(())
127추가: }
128추가: });
129추가: trace.finish(&report);
130추가: let actual = match &report.outcome {
131추가: Outcome::SnapshotFailed(snapshot::Failure {
132추가: cause: snapshot::Error::Callback(value),
133추가: ..
134추가: }) => value,
135추가: Outcome::DecodeFailed(gzip::Error::Callback(value)) => value,
136추가: Outcome::Publication(native) => {
137추가: cleanup(&native.cleanup, 4);
138추가: assert_eq!(native.usage.link_calls, 0);
139추가: match &native.outcome {
140추가: publication::Outcome::NotCommitted(publication::Error::Callback(value)) => value,
141추가: _ => panic!("게시 callback 오류 원형이 사라짐"),
142추가: }
143추가: }
144추가: _ => panic!("callback 오류 원형이 사라짐"),
145추가: };
146추가: assert!(Rc::ptr_eq(actual, &marker));
147추가: assert_eq!(report.usage, trace.points.last().unwrap().usage);
148추가: assert!(target.matches(trace.points.last().unwrap().event));
149추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished);
150추가: assert!(names(&parent).is_empty());
151추가: sandbox.finish();
152추가: }
153추가:
154추가: #[test]
155추가: fn snapshot_observer_error_beats_accepted_cancel() {
156추가: observer_error(Target::Snapshot(snapshot::Stage::Finalizing));
157추가: }
158추가: #[test]
159추가: fn decode_observer_error_beats_accepted_cancel() {
160추가: observer_error(Target::Decode(gzip::Stage::AfterOutput));
161추가: }
162추가: #[test]
163추가: fn publication_observer_error_beats_accepted_cancel() {
164추가: observer_error(Target::Publication(publication::Stage::BeforeCommit));
165추가: }
166추가:
167추가: #[test]
168추가: fn local_snapshot_stop_does_not_need_cancel_request() {
169추가: cancel_at(Target::Snapshot(snapshot::Stage::Comparing), true);
170추가: }
171추가: #[test]
172추가: fn local_decode_stop_does_not_need_cancel_request() {
173추가: cancel_at(Target::Decode(gzip::Stage::AfterOutput), true);
174추가: }
175추가: #[test]
176추가: fn local_publication_stop_does_not_need_cancel_request() {
177추가: cancel_at(Target::Publication(publication::Stage::BeforeCommit), true);
178추가: }
179추가:
180추가: #[test]
181추가: fn cancellation_after_return_preserves_committed_bytes() {
182추가: let sandbox = Sandbox::new();
183추가: let archive = stored(b"abc");
184추가: let input = sandbox.file("input.gz", &archive);
185추가: let parent = sandbox.parent();
186추가: let (task, cancel) = FileJob::new();
187추가: let report = task.run(request(&input, &parent, Limits::default()), |_| {
188추가: Ok::<_, Stop<()>>(())
189추가: });
190추가: let before = identity(&parent.join("output"));
191추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished);
192추가: assert_eq!(
193추가: cancel.clone().request(),
194추가: publication::CancelDecision::Finished
195추가: );
196추가: committed(&report, &parent, b"abc");
197추가: assert_eq!(identity(&parent.join("output")), before);
198추가: assert_eq!(fs::read(&input).unwrap(), archive);
199추가: sandbox.finish();
200추가: }
201추가:
202추가: #[test]
203추가: fn dropping_unused_job_finishes_its_gate() {
204추가: let (task, cancel) = FileJob::new();
205추가: drop(task);
206추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished);
207추가: }
208추가:
209추가: #[test]
210추가: fn cancel_snapshot_opening() {
211추가: cancel_at(Target::Snapshot(snapshot::Stage::Opening), false);
212추가: }
213추가:
214추가: #[test]
215추가: fn cancel_snapshot_pinned() {
216추가: cancel_at(Target::Snapshot(snapshot::Stage::Pinned), false);
217추가: }
218추가:
219추가: #[test]
220추가: fn cancel_snapshot_copying() {
221추가: cancel_at(Target::Snapshot(snapshot::Stage::Copying), false);
222추가: }
223추가:
224추가: #[test]
225추가: fn cancel_snapshot_comparing() {
226추가: cancel_at(Target::Snapshot(snapshot::Stage::Comparing), false);
227추가: }
228추가:
229추가: #[test]
230추가: fn cancel_snapshot_finalizing() {
231추가: cancel_at(Target::Snapshot(snapshot::Stage::Finalizing), false);
232추가: }
233추가:
234추가: #[test]
235추가: fn cancel_decode_start() {
236추가: cancel_at(Target::Decode(gzip::Stage::Start), false);
237추가: }
238추가:
239추가: #[test]
240추가: fn cancel_decode_header() {
241추가: cancel_at(Target::Decode(gzip::Stage::Header), false);
242추가: }
243추가:
244추가: #[test]
245추가: fn cancel_decode_before_inflate() {
246추가: cancel_at(Target::Decode(gzip::Stage::BeforeInflate), false);
247추가: }
248추가:
249추가: #[test]
250추가: fn cancel_decode_after_inflate() {
251추가: cancel_at(Target::Decode(gzip::Stage::AfterInflate), false);
252추가: }
253추가:
254추가: #[test]
255추가: fn cancel_decode_after_output() {
256추가: cancel_at(Target::Decode(gzip::Stage::AfterOutput), false);
257추가: }
258추가:
259추가: #[test]
260추가: fn cancel_decode_trailer() {
261추가: cancel_at(Target::Decode(gzip::Stage::Trailer), false);
262추가: }
263추가:
264추가: #[test]
265추가: fn cancel_decode_before_return() {
266추가: cancel_at(Target::Decode(gzip::Stage::BeforeReturn), false);
267추가: }
268추가:
269추가: #[test]
270추가: fn cancel_publication_opening() {
271추가: cancel_at(Target::Publication(publication::Stage::Opening), false);
272추가: }
273추가:
274추가: #[test]
275추가: fn cancel_publication_writing() {
276추가: cancel_at(Target::Publication(publication::Stage::Writing), false);
277추가: }
278추가:
279추가: #[test]
280추가: fn cancel_publication_verifying() {
281추가: cancel_at(Target::Publication(publication::Stage::Verifying), false);
282추가: }
283추가:
284추가: #[test]
285추가: fn cancel_publication_before_commit() {
286추가: cancel_at(Target::Publication(publication::Stage::BeforeCommit), false);
287추가: }
추가tests/rust-gzip-file-job/fixtures.rs+39-0
@@ -0,0 +1,39 @@
1추가: pub fn pattern(length: usize) -> Vec<u8> {
2추가: (0..length).map(|i| ((i * 37 + 11) % 251) as u8).collect()
3추가: }
4추가:
5추가: pub fn crc32(bytes: &[u8]) -> u32 {
6추가: let mut value = !0_u32;
7추가: for byte in bytes {
8추가: value ^= u32::from(*byte);
9추가: for _ in 0..8 {
10추가: value = (value >> 1) ^ (0xedb8_8320 & 0_u32.wrapping_sub(value & 1));
11추가: }
12추가: }
13추가: !value
14추가: }
15추가:
16추가: pub fn stored(bytes: &[u8]) -> Vec<u8> {
17추가: assert!(bytes.len() <= 65_537);
18추가: let mut archive = vec![0x1f, 0x8b, 8, 0, 0, 0, 0, 0, 0, 255];
19추가: let blocks = bytes.len().max(1).div_ceil(65_535);
20추가: for index in 0..blocks {
21추가: let start = index * 65_535;
22추가: let end = (start + 65_535).min(bytes.len());
23추가: let length = (end - start) as u16;
24추가: archive.push(u8::from(index + 1 == blocks));
25추가: archive.extend_from_slice(&length.to_le_bytes());
26추가: archive.extend_from_slice(&(!length).to_le_bytes());
27추가: archive.extend_from_slice(&bytes[start..end]);
28추가: }
29추가: archive.extend_from_slice(&crc32(bytes).to_le_bytes());
30추가: archive.extend_from_slice(&(bytes.len() as u32).to_le_bytes());
31추가: archive
32추가: }
33추가:
34추가: pub fn named(bytes: &[u8]) -> Vec<u8> {
35추가: let mut archive = stored(bytes);
36추가: archive[3] = 8 | 16;
37추가: archive.splice(10..10, b"../header-name\0../comment-name\0".iter().copied());
38추가: archive
39추가: }
추가tests/rust-gzip-file-job/invalid.rs+72-0
@@ -0,0 +1,72 @@
1추가: use crate::{fixtures::*, support::*};
2추가: use job::{Limits, Outcome, gzip};
3추가:
4추가: fn rejected(archive: Vec<u8>, expected: Option<gzip::Failure>) {
5추가: let sandbox = Sandbox::new();
6추가: let input = sandbox.file("input.gz", &archive);
7추가: let before = identity(&input);
8추가: let parent = sandbox.parent();
9추가: let (report, trace) = run(&input, &parent, Limits::default());
10추가: match (&report.outcome, expected) {
11추가: (Outcome::DecodeFailed(gzip::Error::Reader(actual)), Some(expected)) => {
12추가: assert_eq!(*actual, expected)
13추가: }
14추가: (Outcome::DecodeFailed(gzip::Error::Backend(_)), None) => {}
15추가: _ => panic!("원래 GZip 실패 종류가 보존되지 않음"),
16추가: }
17추가: trace.finish(&report);
18추가: snapshot_usage(report.usage.snapshot, archive.len());
19추가: assert_eq!(
20추가: report.snapshot.as_ref().unwrap().identity().inode(),
21추가: before.1
22추가: );
23추가: assert!(names(&parent).is_empty());
24추가: assert_eq!(identity(&input), before);
25추가: assert_eq!(std::fs::read(input).unwrap(), archive);
26추가: sandbox.finish();
27추가: }
28추가:
29추가: #[test]
30추가: fn invalid_magic_prevents_publication() {
31추가: let mut archive = stored(b"abc");
32추가: archive[0] = 0;
33추가: rejected(archive, Some(gzip::Failure::Header));
34추가: }
35추가: #[test]
36추가: fn invalid_deflate_preserves_backend_error() {
37추가: let mut archive = stored(b"abc");
38추가: archive[10] = 7;
39추가: rejected(archive, None);
40추가: }
41추가: #[test]
42추가: fn bad_crc_prevents_publication() {
43추가: let mut archive = stored(b"abc");
44추가: let index = archive.len() - 8;
45추가: archive[index] ^= 1;
46추가: rejected(archive, Some(gzip::Failure::Crc));
47추가: }
48추가: #[test]
49추가: fn bad_size_prevents_publication() {
50추가: let mut archive = stored(b"abc");
51추가: let index = archive.len() - 4;
52추가: archive[index] ^= 1;
53추가: rejected(archive, Some(gzip::Failure::Size));
54추가: }
55추가: #[test]
56추가: fn concatenated_members_prevent_publication() {
57추가: let mut archive = stored(b"abc");
58추가: archive.extend(stored(b"def"));
59추가: rejected(archive, Some(gzip::Failure::TrailingData));
60추가: }
61추가: #[test]
62추가: fn trailing_byte_prevents_publication() {
63추가: let mut archive = stored(b"abc");
64추가: archive.push(0);
65추가: rejected(archive, Some(gzip::Failure::TrailingData));
66추가: }
67추가: #[test]
68추가: fn truncated_trailer_prevents_publication() {
69추가: let mut archive = stored(b"abc");
70추가: archive.pop();
71추가: rejected(archive, Some(gzip::Failure::Truncated));
72추가: }
추가tests/rust-gzip-file-job/limits.rs+273-0
@@ -0,0 +1,273 @@
1추가: use crate::{fixtures::*, support::*};
2추가: use job::{Limits, Outcome, gzip, publication, snapshot};
3추가: use std::time::Duration;
4추가:
5추가: fn snapshot_limit(kind: snapshot::LimitKind) {
6추가: let sandbox = Sandbox::new();
7추가: let archive = stored(b"abc");
8추가: let length = archive.len() as u64;
9추가: let input = sandbox.file("input.gz", &archive);
10추가: let parent = sandbox.parent();
11추가: let mut limits = Limits::default();
12추가: match kind {
13추가: snapshot::LimitKind::Bytes => limits.snapshot.max_bytes = length - 1,
14추가: snapshot::LimitKind::IoBytes => limits.snapshot.max_io_bytes = 2 * length + 1,
15추가: snapshot::LimitKind::ReadCalls => limits.snapshot.max_read_calls = 3,
16추가: _ => unreachable!(),
17추가: }
18추가: let (report, _) = run(&input, &parent, limits);
19추가: match &report.outcome {
20추가: Outcome::SnapshotFailed(snapshot::Failure {
21추가: cause: snapshot::Error::Limit(actual),
22추가: usage,
23추가: }) => {
24추가: assert_eq!(*actual, kind);
25추가: assert_eq!(*usage, report.usage.snapshot);
26추가: }
27추가: _ => panic!("snapshot 한도 오류가 아님"),
28추가: }
29추가: let expected = if kind == snapshot::LimitKind::Bytes {
30추가: snapshot::Usage {
31추가: open_calls: 1,
32추가: metadata_calls: 1,
33추가: ..snapshot::Usage::default()
34추가: }
35추가: } else {
36추가: snapshot::Usage {
37추가: open_calls: 4,
38추가: metadata_calls: 4,
39추가: read_calls: 3,
40추가: reserved_read_bytes: 2 * length + 1,
41추가: actual_read_bytes: 2 * length,
42추가: compared_bytes: length,
43추가: }
44추가: };
45추가: assert_eq!(report.usage.snapshot, expected);
46추가: assert!(names(&parent).is_empty());
47추가: sandbox.finish();
48추가: }
49추가: #[test]
50추가: fn snapshot_byte_limit_preserves_partial_usage() {
51추가: snapshot_limit(snapshot::LimitKind::Bytes);
52추가: }
53추가: #[test]
54추가: fn snapshot_io_limit_retains_last_eof_reservation_boundary() {
55추가: snapshot_limit(snapshot::LimitKind::IoBytes);
56추가: }
57추가: #[test]
58추가: fn snapshot_call_limit_retains_last_eof_reservation_boundary() {
59추가: snapshot_limit(snapshot::LimitKind::ReadCalls);
60추가: }
61추가:
62추가: fn gzip_limit(field: &str) {
63추가: let sandbox = Sandbox::new();
64추가: let archive = stored(b"abc");
65추가: let length = archive.len() as u64;
66추가: let input = sandbox.file("input.gz", &archive);
67추가: let parent = sandbox.parent();
68추가: let mut limits = Limits::default();
69추가: let expected = match field {
70추가: "input" => {
71추가: limits.gzip.input = length - 1;
72추가: gzip::Usage::default()
73추가: }
74추가: "processed" => {
75추가: limits.gzip.processed = length + 2;
76추가: gzip::Usage {
77추가: processed: length + 3,
78추가: output: 0,
79추가: metadata: 10,
80추가: }
81추가: }
82추가: "output" => {
83추가: limits.gzip.output = 2;
84추가: gzip::Usage {
85추가: processed: length + 3,
86추가: output: 0,
87추가: metadata: 10,
88추가: }
89추가: }
90추가: "metadata" => {
91추가: limits.gzip.metadata = 9;
92추가: gzip::Usage {
93추가: processed: 9,
94추가: output: 0,
95추가: metadata: 9,
96추가: }
97추가: }
98추가: _ => unreachable!(),
99추가: };
100추가: let (report, trace) = run(&input, &parent, limits);
101추가: assert!(matches!(
102추가: report.outcome,
103추가: Outcome::DecodeFailed(gzip::Error::Reader(gzip::Failure::Budget))
104추가: ));
105추가: assert_eq!(report.usage.gzip, expected);
106추가: snapshot_usage(report.usage.snapshot, archive.len());
107추가: if field == "processed" {
108추가: assert!(report.usage.gzip.processed > trace.points.last().unwrap().usage.gzip.processed);
109추가: }
110추가: assert!(names(&parent).is_empty());
111추가: sandbox.finish();
112추가: }
113추가: #[test]
114추가: fn gzip_input_limit_stops_after_snapshot() {
115추가: gzip_limit("input");
116추가: }
117추가: #[test]
118추가: fn gzip_processed_failure_includes_post_checkpoint_charge() {
119추가: gzip_limit("processed");
120추가: }
121추가: #[test]
122추가: fn gzip_selected_output_limit_preserves_consumed_cost() {
123추가: gzip_limit("output");
124추가: }
125추가: #[test]
126추가: fn gzip_metadata_limit_preserves_header_cost() {
127추가: gzip_limit("metadata");
128추가: }
129추가:
130추가: fn publication_limit(field: &str) {
131추가: let sandbox = Sandbox::new();
132추가: let archive = stored(b"abc");
133추가: let input = sandbox.file("input.gz", &archive);
134추가: let parent = sandbox.parent();
135추가: let mut limits = Limits::default();
136추가: match field {
137추가: "bytes" => limits.publication.max_bytes = 2,
138추가: "io" => limits.publication.max_io_bytes = 6,
139추가: "calls" => limits.publication.max_io_calls = 2,
140추가: _ => unreachable!(),
141추가: }
142추가: let (report, _) = run(&input, &parent, limits);
143추가: let native = match &report.outcome {
144추가: Outcome::Publication(native) => native,
145추가: _ => panic!("게시 단계 미도달"),
146추가: };
147추가: assert!(matches!(
148추가: native.outcome,
149추가: publication::Outcome::NotCommitted(publication::Error::LimitExceeded)
150추가: ));
151추가: let expected = if field == "bytes" {
152추가: cleanup(&native.cleanup, 0);
153추가: publication::Usage::default()
154추가: } else {
155추가: cleanup(&native.cleanup, 2);
156추가: publication::Usage {
157추가: open_calls: 2,
158추가: metadata_calls: 3,
159추가: sync_calls: 1,
160추가: write_calls: 1,
161추가: read_calls: 1,
162추가: reserved_io_bytes: 6,
163추가: actual_written_bytes: 3,
164추가: actual_read_bytes: 3,
165추가: ..publication::Usage::default()
166추가: }
167추가: };
168추가: assert_eq!(report.usage.publication, expected);
169추가: snapshot_usage(report.usage.snapshot, archive.len());
170추가: gzip_usage(report.usage.gzip, &archive, b"abc", 10);
171추가: assert!(names(&parent).is_empty());
172추가: sandbox.finish();
173추가: }
174추가: #[test]
175추가: fn publication_byte_limit_preserves_completed_prior_stages() {
176추가: publication_limit("bytes");
177추가: }
178추가: #[test]
179추가: fn publication_io_limit_retains_pre_eof_usage() {
180추가: publication_limit("io");
181추가: }
182추가: #[test]
183추가: fn publication_call_limit_retains_pre_eof_usage() {
184추가: publication_limit("calls");
185추가: }
186추가:
187추가: #[test]
188추가: fn exact_limits_in_all_stages_allow_commit() {
189추가: let sandbox = Sandbox::new();
190추가: let archive = stored(b"abc");
191추가: let length = archive.len() as u64;
192추가: let input = sandbox.file("input.gz", &archive);
193추가: let before = identity(&input);
194추가: let parent = sandbox.parent();
195추가: let limits = Limits {
196추가: snapshot: snapshot::Limits {
197추가: max_bytes: length,
198추가: max_io_bytes: 2 * length + 2,
199추가: max_read_calls: 4,
200추가: ..snapshot::Limits::default()
201추가: },
202추가: gzip: gzip::Limits {
203추가: input: length,
204추가: processed: length + 3,
205추가: output: 3,
206추가: metadata: 10,
207추가: ..gzip::Limits::default()
208추가: },
209추가: publication: publication::Limits {
210추가: max_bytes: 3,
211추가: max_io_bytes: 7,
212추가: max_io_calls: 3,
213추가: ..publication::Limits::default()
214추가: },
215추가: };
216추가: let (report, _) = run(&input, &parent, limits);
217추가: observations(&report, (before.0, before.1), &archive, b"abc", 10);
218추가: committed(&report, &parent, b"abc");
219추가: sandbox.finish();
220추가: }
221추가:
222추가: fn invalid_duration(stage: u8) {
223추가: let sandbox = Sandbox::new();
224추가: let archive = stored(b"abc");
225추가: let input = sandbox.file("input.gz", &archive);
226추가: let parent = sandbox.parent();
227추가: let mut limits = Limits::default();
228추가: match stage {
229추가: 0 => limits.snapshot.max_duration = Duration::ZERO,
230추가: 1 => limits.gzip.duration = Duration::ZERO,
231추가: 2 => limits.publication.max_duration = Duration::ZERO,
232추가: _ => unreachable!(),
233추가: }
234추가: let (report, trace) = run(&input, &parent, limits);
235추가: match (&report.outcome, stage) {
236추가: (Outcome::SnapshotFailed(failure), 0) => {
237추가: assert!(matches!(failure.cause, snapshot::Error::InvalidLimits));
238추가: assert_eq!(report.usage, job::Usage::default());
239추가: assert!(trace.points.is_empty());
240추가: }
241추가: (Outcome::DecodeFailed(gzip::Error::Reader(gzip::Failure::InvalidRequest)), 1) => {
242추가: snapshot_usage(report.usage.snapshot, archive.len());
243추가: assert_eq!(report.usage.gzip, gzip::Usage::default());
244추가: assert!(trace.points.iter().all(|p| phase(p.event) == 0));
245추가: }
246추가: (Outcome::Publication(native), 2) => {
247추가: snapshot_usage(report.usage.snapshot, archive.len());
248추가: gzip_usage(report.usage.gzip, &archive, b"abc", 10);
249추가: assert!(matches!(
250추가: native.outcome,
251추가: publication::Outcome::NotCommitted(publication::Error::InvalidLimits)
252추가: ));
253추가: assert_eq!(native.usage, publication::Usage::default());
254추가: cleanup(&native.cleanup, 0);
255추가: assert!(trace.points.iter().all(|p| phase(p.event) <= 1));
256추가: }
257추가: _ => panic!("단계별 잘못된 한도 오류가 아님"),
258추가: }
259추가: assert!(names(&parent).is_empty());
260추가: sandbox.finish();
261추가: }
262추가: #[test]
263추가: fn invalid_snapshot_duration_has_zero_cost() {
264추가: invalid_duration(0);
265추가: }
266추가: #[test]
267추가: fn invalid_decode_duration_retains_snapshot_cost() {
268추가: invalid_duration(1);
269추가: }
270추가: #[test]
271추가: fn invalid_publication_duration_retains_both_prior_costs() {
272추가: invalid_duration(2);
273추가: }
추가tests/rust-gzip-file-job/main.rs+10-0
@@ -0,0 +1,10 @@
1추가: #![cfg(target_os = "linux")]
2추가:
3추가: mod concurrency;
4추가: mod control;
5추가: mod fixtures;
6추가: mod invalid;
7추가: mod limits;
8추가: mod namespace;
9추가: mod success;
10추가: mod support;
추가tests/rust-gzip-file-job/namespace.rs+138-0
@@ -0,0 +1,138 @@
1추가: use crate::{fixtures::*, support::*};
2추가: use job::{Event, FileJob, Limits, Outcome, Stop, publication, snapshot};
3추가: use std::{ffi::OsStr, fs, os::unix::fs::symlink};
4추가:
5추가: #[test]
6추가: fn existing_file_bytes_and_identity_survive_conflict() {
7추가: let sandbox = Sandbox::new();
8추가: let input = sandbox.file("input.gz", &stored(b"abc"));
9추가: let existing = sandbox.file("parent/output", b"preserve");
10추가: let before = identity(&existing);
11추가: let (report, _) = run(&input, &sandbox.parent(), Limits::default());
12추가: conflict(&report, 3);
13추가: assert_eq!(fs::read(&existing).unwrap(), b"preserve");
14추가: assert_eq!(identity(&existing), before);
15추가: assert_eq!(
16추가: names(&sandbox.parent()),
17추가: vec![std::ffi::OsString::from("output")]
18추가: );
19추가: sandbox.finish();
20추가: }
21추가:
22추가: #[test]
23추가: fn existing_directory_and_child_survive_conflict() {
24추가: let sandbox = Sandbox::new();
25추가: let input = sandbox.file("input.gz", &stored(b"abc"));
26추가: let existing = sandbox.dir("parent/output");
27추가: let child = sandbox.file("parent/output/child", b"preserve");
28추가: let before = identity(&existing);
29추가: let child_before = identity(&child);
30추가: let (report, _) = run(&input, &sandbox.parent(), Limits::default());
31추가: conflict(&report, 3);
32추가: assert_eq!(identity(&existing), before);
33추가: assert_eq!(identity(&child), child_before);
34추가: assert_eq!(fs::read(child).unwrap(), b"preserve");
35추가: assert_eq!(names(&existing), vec![std::ffi::OsString::from("child")]);
36추가: sandbox.finish();
37추가: }
38추가:
39추가: #[test]
40추가: fn existing_symlink_and_target_survive_conflict() {
41추가: let sandbox = Sandbox::new();
42추가: let input = sandbox.file("input.gz", &stored(b"abc"));
43추가: let victim = sandbox.file("victim", b"preserve");
44추가: let existing = sandbox.parent().join("output");
45추가: symlink(&victim, &existing).unwrap();
46추가: let before = identity(&existing);
47추가: let victim_before = identity(&victim);
48추가: let (report, _) = run(&input, &sandbox.parent(), Limits::default());
49추가: conflict(&report, 3);
50추가: assert_eq!(identity(&existing), before);
51추가: assert_eq!(identity(&victim), victim_before);
52추가: assert_eq!(fs::read_link(existing).unwrap(), victim);
53추가: assert_eq!(fs::read(victim).unwrap(), b"preserve");
54추가: sandbox.finish();
55추가: }
56추가:
57추가: #[test]
58추가: fn identical_input_and_output_name_preserves_archive() {
59추가: let sandbox = Sandbox::new();
60추가: let archive = stored(b"abc");
61추가: let input = sandbox.file("input.gz", &archive);
62추가: let before = identity(&input);
63추가: let (task, cancel) = FileJob::new();
64추가: let mut trace = Trace::default();
65추가: let report = task.run(
66추가: job::Request {
67추가: input: &input,
68추가: output_parent: &sandbox.root,
69추가: output_leaf: OsStr::new("input.gz"),
70추가: limits: Limits::default(),
71추가: },
72추가: |point| {
73추가: trace.push(point);
74추가: Ok::<_, Stop<()>>(())
75추가: },
76추가: );
77추가: trace.finish(&report);
78추가: conflict(&report, 3);
79추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished);
80추가: assert_eq!(identity(&input), before);
81추가: assert_eq!(fs::read(input).unwrap(), archive);
82추가: sandbox.finish();
83추가: }
84추가:
85추가: #[test]
86추가: fn missing_owned_input_preserves_native_open_error() {
87추가: let sandbox = Sandbox::new();
88추가: let (report, trace) = run(
89추가: &sandbox.path("missing.gz"),
90추가: &sandbox.parent(),
91추가: Limits::default(),
92추가: );
93추가: match &report.outcome {
94추가: Outcome::SnapshotFailed(snapshot::Failure {
95추가: cause: snapshot::Error::Io { operation, source },
96추가: usage,
97추가: }) => {
98추가: assert_eq!(*operation, snapshot::IoOperation::PinPath);
99추가: assert_eq!(source.raw_os_error(), Some(libc::ENOENT));
100추가: assert_eq!(
101추가: *usage,
102추가: snapshot::Usage {
103추가: open_calls: 1,
104추가: ..snapshot::Usage::default()
105추가: }
106추가: );
107추가: }
108추가: _ => panic!("원래 입력 open 오류가 아님"),
109추가: }
110추가: trace.finish(&report);
111추가: assert!(names(&sandbox.parent()).is_empty());
112추가: sandbox.finish();
113추가: }
114추가:
115추가: #[test]
116추가: fn replaced_parent_path_does_not_redirect_pinned_commit() {
117추가: let sandbox = Sandbox::new();
118추가: let input = sandbox.file("input.gz", &stored(b"abc"));
119추가: let parent = sandbox.parent();
120추가: let (task, cancel) = FileJob::new();
121추가: let mut trace = Trace::default();
122추가: let mut replaced = false;
123추가: let report = task.run(request(&input, &parent, Limits::default()), |point| {
124추가: trace.push(point);
125추가: if matches!(point.event, Event::Publication(native) if native.stage == publication::Stage::BeforeCommit) {
126추가: fs::rename(&parent, sandbox.path("old-parent")).unwrap();
127추가: sandbox.dir("parent");
128추가: replaced = true;
129추가: }
130추가: Ok::<_, Stop<()>>(())
131추가: });
132추가: assert!(replaced);
133추가: trace.finish(&report);
134추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished);
135추가: committed(&report, &sandbox.path("old-parent"), b"abc");
136추가: assert!(names(&parent).is_empty());
137추가: sandbox.finish();
138추가: }
추가tests/rust-gzip-file-job/run-plan.json+117-0
@@ -0,0 +1,117 @@
1추가: {
2추가: "schema": "zipelo.gzip-file-job-run-plan.v1",
3추가: "gate": "No Rust compile/discovery/FileJob execution before fixed head/manifest review. rustfmt parsing, offline lock/metadata and Python static helper tests only in preparation.",
4추가: "preflight": [
5추가: "Blocking exclusive current workspace flock for every file write/build/cache mutation; fresh status and fixed input check inside lock. No source/branch checkout changes in shared workspace.",
6추가: "Verify 39 remote source blobs/modes/SHA256 and complete new manifest; existing Rust1.99.1 and offline registry graph only.",
7추가: "Fresh canonical owned validation and target under this tests path; refuse previous result/target reuse after failure. Preserve all old evidence.",
8추가: "Create runs with mode0700 only if absent under the canonical test root; verify euid and identity. Child Sandbox creates mode0700 private case root, files0600. No chmod/chown of existing paths.",
9추가: "Native Linux ext-family/XFS with procfs/openat2/O_TMPFILE only; unexpected Unsupported is a failed environment prerequisite, never skip/ignore/success. No mount/permission workaround.",
10추가: "Independent synthetic fixtures only. Maximum plain payload65537 and compressed fixture <=65599 bytes; two publishers only in concurrency case."
11추가: ],
12추가: "target": {
13추가: "manifest": "tests/rust-gzip-file-job/Cargo.toml",
14추가: "name": "file_job_public_api",
15추가: "exact_names": [
16추가: "concurrency::acknowledged_external_cancel_before_commit_prevents_publication",
17추가: "concurrency::two_file_jobs_for_one_name_have_one_complete_winner",
18추가: "control::cancel_decode_after_inflate",
19추가: "control::cancel_decode_after_output",
20추가: "control::cancel_decode_before_inflate",
21추가: "control::cancel_decode_before_return",
22추가: "control::cancel_decode_header",
23추가: "control::cancel_decode_start",
24추가: "control::cancel_decode_trailer",
25추가: "control::cancel_publication_before_commit",
26추가: "control::cancel_publication_opening",
27추가: "control::cancel_publication_verifying",
28추가: "control::cancel_publication_writing",
29추가: "control::cancel_snapshot_comparing",
30추가: "control::cancel_snapshot_copying",
31추가: "control::cancel_snapshot_finalizing",
32추가: "control::cancel_snapshot_opening",
33추가: "control::cancel_snapshot_pinned",
34추가: "control::cancellation_after_return_preserves_committed_bytes",
35추가: "control::decode_observer_error_beats_accepted_cancel",
36추가: "control::dropping_unused_job_finishes_its_gate",
37추가: "control::local_decode_stop_does_not_need_cancel_request",
38추가: "control::local_publication_stop_does_not_need_cancel_request",
39추가: "control::local_snapshot_stop_does_not_need_cancel_request",
40추가: "control::pre_cancel_stops_before_snapshot_open",
41추가: "control::publication_observer_error_beats_accepted_cancel",
42추가: "control::snapshot_observer_error_beats_accepted_cancel",
43추가: "invalid::bad_crc_prevents_publication",
44추가: "invalid::bad_size_prevents_publication",
45추가: "invalid::concatenated_members_prevent_publication",
46추가: "invalid::invalid_deflate_preserves_backend_error",
47추가: "invalid::invalid_magic_prevents_publication",
48추가: "invalid::trailing_byte_prevents_publication",
49추가: "invalid::truncated_trailer_prevents_publication",
50추가: "limits::exact_limits_in_all_stages_allow_commit",
51추가: "limits::gzip_input_limit_stops_after_snapshot",
52추가: "limits::gzip_metadata_limit_preserves_header_cost",
53추가: "limits::gzip_processed_failure_includes_post_checkpoint_charge",
54추가: "limits::gzip_selected_output_limit_preserves_consumed_cost",
55추가: "limits::invalid_decode_duration_retains_snapshot_cost",
56추가: "limits::invalid_publication_duration_retains_both_prior_costs",
57추가: "limits::invalid_snapshot_duration_has_zero_cost",
58추가: "limits::publication_byte_limit_preserves_completed_prior_stages",
59추가: "limits::publication_call_limit_retains_pre_eof_usage",
60추가: "limits::publication_io_limit_retains_pre_eof_usage",
61추가: "limits::snapshot_byte_limit_preserves_partial_usage",
62추가: "limits::snapshot_call_limit_retains_last_eof_reservation_boundary",
63추가: "limits::snapshot_io_limit_retains_last_eof_reservation_boundary",
64추가: "namespace::existing_directory_and_child_survive_conflict",
65추가: "namespace::existing_file_bytes_and_identity_survive_conflict",
66추가: "namespace::existing_symlink_and_target_survive_conflict",
67추가: "namespace::identical_input_and_output_name_preserves_archive",
68추가: "namespace::missing_owned_input_preserves_native_open_error",
69추가: "namespace::replaced_parent_path_does_not_redirect_pinned_commit",
70추가: "success::chunk_minus_one_output",
71추가: "success::chunk_output",
72추가: "success::chunk_plus_one_output",
73추가: "success::empty_output",
74추가: "success::header_name_and_comment_never_select_destination",
75추가: "success::known_bytes_output",
76추가: "success::one_byte_output",
77추가: "success::replacing_input_after_snapshot_uses_captured_owned_bytes"
78추가: ],
79추가: "count": 62,
80추가: "filtered_per_case": 61
81추가: },
82추가: "commands": [
83추가: "python3 -B tests/rust-gzip-file-job/static_check.py --manifest-sha256 <fixed>",
84추가: "cargo test --manifest-path tests/rust-gzip-file-job/Cargo.toml --locked --offline --test file_job_public_api --no-run --message-format=json",
85추가: "<unique-binary> --list --format terse",
86추가: "<unique-binary> --exact <name> --test-threads=1 --nocapture"
87추가: ],
88추가: "bounds": {
89추가: "compile_seconds": 120,
90추가: "discovery_seconds": 30,
91추가: "per_case_seconds": 30,
92추가: "per_command_log_bytes": 8388608,
93추가: "channel_wait_seconds": 5,
94추가: "termination_grace_seconds": 2,
95추가: "reap_grace_seconds": 5,
96추가: "cleanup_observation_seconds": 10,
97추가: "parallel_cases": 1,
98추가: "max_payload_bytes": 65537,
99추가: "max_archive_bytes": 65599
100추가: },
101추가: "order": "Static then compile once, unique artifact and complete exact discovery set, each sorted case exactly once. Require1passed/0failed/0ignored/0measured and61filtered. First failure/timeout/missing/duplicate/changed input stops without retry.",
102추가: "parser": "Handle --nocapture prefix/intermediate output/ok separation; exact unique name and summary plus exit0/reaped/EOF required. Reject malformed/missing/duplicate names or summaries and failed/timeout/capped command. Pre-selftest the runner parser, reusing verified PR54 parser logic only with source/hash record.",
103추가: "supervision": "Stream bounded raw logs, signal only owned process group after timeout/log overflow, TERM grace2s then KILL and reap5s. Channel receives5s; join occurs after done and whole process remains bounded by30s. Never claim hard interrupt of uninterruptible I/O.",
104추가: "cleanup": "Rust assertions/joins finish before Sandbox.finish; no implicit Drop deletion. Preserve failures and their residual case roots. After each passing process require runs empty and owned children/threads ended. Keep logs and binaries. Remove only newly owned empty runs after final identity check; no recursive cleanup of failures.",
105추가: "evidence": "Record source/test hashes before/after, exact names/filtered values, raw stdout/stderr/argv/env, binary SHA256, process exit/reap/EOF, output stage/Usage/cleanup assertions and owned residuals. Preserve original PR48/51/54 reports. Separate real FileJob results from callback scheduling and gate lifecycle.",
106추가: "forbidden": [
107추가: "Production changes",
108추가: "Public receipt constructors",
109추가: "Retries or weakening expectations",
110추가: "User archives or paths",
111추가: "GUI/VM/OS worker/execveat",
112추가: "Windows cfg simulation",
113추가: "System permission/mount changes",
114추가: "Network/install/download",
115추가: "Main merge or product release"
116추가: ]
117추가: }
추가tests/rust-gzip-file-job/source-pins.json+240-0
@@ -0,0 +1,240 @@
1추가: {
2추가: "head": "4c6ae4b3a7ab12a992598e94e7b02f3a167fbbd4",
3추가: "tree": "9a01a37623b163c35ca4ff25963b2e11c61a0c35",
4추가: "files": [
5추가: {
6추가: "path": "experiments/rust-file-publication/Cargo.lock",
7추가: "git_blob": "207c18a163029bf5059414e443d47340f701973e",
8추가: "mode": "100644",
9추가: "sha256": "b38bcde0e0c7286f53254ecbc357a55a0b18e803fd7294dec1025fcb34eb6092"
10추가: },
11추가: {
12추가: "path": "experiments/rust-file-publication/Cargo.toml",
13추가: "git_blob": "769cad258dde0179ea8e32bd3d13a7579a791497",
14추가: "mode": "100644",
15추가: "sha256": "e6d911fb2c215dcab367116b0eac2544a3e37abe0d69ba6f0323c0d0308b329d"
16추가: },
17추가: {
18추가: "path": "experiments/rust-file-publication/LICENSE",
19추가: "git_blob": "5014abac33298592fd3450b51a9b414191e1aabc",
20추가: "mode": "100644",
21추가: "sha256": "0714945e52a4d5b560c02c9a18478519f8c4e2572cbf87bd6d52adcfb2b63c62"
22추가: },
23추가: {
24추가: "path": "experiments/rust-file-publication/SHA256SUMS",
25추가: "git_blob": "b77cca2d6328d6c4512e3c62a65ca0b032937836",
26추가: "mode": "100644",
27추가: "sha256": "cc4e4cc64a8f3b537df554c7d2895ea3722fbfb0906f1ada767d5cf9b5d8bbc6"
28추가: },
29추가: {
30추가: "path": "experiments/rust-file-publication/THIRD-PARTY-NOTICES.txt",
31추가: "git_blob": "fba3cf10cd0ff76bb025c1ff9cee6f17b4844197",
32추가: "mode": "100644",
33추가: "sha256": "83bd16a9177040f87f726c5ff9c0e14e7e3fc0096c743abe0d7b1b97ab1fc425"
34추가: },
35추가: {
36추가: "path": "experiments/rust-file-publication/contract.json",
37추가: "git_blob": "e348369c0f9f0f0bb5bab9b26b4ed4659aac134b",
38추가: "mode": "100644",
39추가: "sha256": "fc091b378311e5a5898f770b4a91317ada5d2daebbb3cfb795e1026736334161"
40추가: },
41추가: {
42추가: "path": "experiments/rust-file-publication/dependencies.json",
43추가: "git_blob": "85b978be36080547024565031bc6a433e6a4b321",
44추가: "mode": "100644",
45추가: "sha256": "75757b6b770ea09d7b345ca3beaf3d75fdbbe7c792d00d3aec7465b9968ce4f5"
46추가: },
47추가: {
48추가: "path": "experiments/rust-file-publication/src/lib.rs",
49추가: "git_blob": "19dcc817be97c8cbb18cb863b98ce6524e164406",
50추가: "mode": "100644",
51추가: "sha256": "8304a9c37e8d0a2e21f6657483c58d28c23ba4a4c2ed9ae7e43d389d0f3c2bc3"
52추가: },
53추가: {
54추가: "path": "experiments/rust-file-publication/src/linux.rs",
55추가: "git_blob": "75a7194329af66458195b08e64d3e96a08495110",
56추가: "mode": "100644",
57추가: "sha256": "75225159189cb2418b24c5e35c4db804dfe2f0171bf957f59578ae284f046d0c"
58추가: },
59추가: {
60추가: "path": "experiments/rust-file-publication/static-validation.json",
61추가: "git_blob": "7ac04313d01dd90ac905275c2e08cd2991789656",
62추가: "mode": "100644",
63추가: "sha256": "75ed00e7059990abe5c3ba7bc0aae87801e3ffa915824c900d09ed31a61f8159"
64추가: },
65추가: {
66추가: "path": "experiments/rust-file-snapshot/Cargo.lock",
67추가: "git_blob": "f78b06aafe24e649c3b8dbf1e80f84875665916d",
68추가: "mode": "100644",
69추가: "sha256": "ba55ac17dc748d1f91d7a6e5d5ebb4c6b9c84d09173a17d4cac31cf149fb771b"
70추가: },
71추가: {
72추가: "path": "experiments/rust-file-snapshot/Cargo.toml",
73추가: "git_blob": "5f13cef3e22861c18da16a0aa45ed990a448d1bf",
74추가: "mode": "100644",
75추가: "sha256": "e641f091c0acabd3e6fbfa3ed6bf53e05be3ca6c2fc90d67980721b378840f0f"
76추가: },
77추가: {
78추가: "path": "experiments/rust-file-snapshot/LICENSE",
79추가: "git_blob": "5014abac33298592fd3450b51a9b414191e1aabc",
80추가: "mode": "100644",
81추가: "sha256": "0714945e52a4d5b560c02c9a18478519f8c4e2572cbf87bd6d52adcfb2b63c62"
82추가: },
83추가: {
84추가: "path": "experiments/rust-file-snapshot/SHA256SUMS",
85추가: "git_blob": "76201cbad9d40111091cb320744f59bb07b4bc65",
86추가: "mode": "100644",
87추가: "sha256": "668b1c3f140a033a6a0768b84ec52f111ee5fbfaf707632d2fc9a5a380758120"
88추가: },
89추가: {
90추가: "path": "experiments/rust-file-snapshot/THIRD-PARTY-NOTICES.txt",
91추가: "git_blob": "c18cb9011479d97d247bf403c128e5923fa769c9",
92추가: "mode": "100644",
93추가: "sha256": "066b8c0623b870c0c3998a0499b0323f3cfe8d3cfd60bf6bbc833be0e523a06e"
94추가: },
95추가: {
96추가: "path": "experiments/rust-file-snapshot/contract.json",
97추가: "git_blob": "93c7b53f2441eee3d98db58dcca8ece47b1094d6",
98추가: "mode": "100644",
99추가: "sha256": "8b54705382c3af1168b684fbcf3e25efd256eb145c636972fe6e26b8cb898ff2"
100추가: },
101추가: {
102추가: "path": "experiments/rust-file-snapshot/dependencies.json",
103추가: "git_blob": "cf8c2f473069573ba29b9cf278d7a09eac83adca",
104추가: "mode": "100644",
105추가: "sha256": "ea113f15ec27f9903eed985e1e55f49114b9867b0c7c707e2cd15009fa02c6c0"
106추가: },
107추가: {
108추가: "path": "experiments/rust-file-snapshot/src/lib.rs",
109추가: "git_blob": "b119facbf8cef61cb1877b7cef9f921f4d63d311",
110추가: "mode": "100644",
111추가: "sha256": "e087714fc3e30b8efdd1cf16e1d8944ebc3518c757b8917d6e32d3b3dc3936c9"
112추가: },
113추가: {
114추가: "path": "experiments/rust-file-snapshot/src/linux.rs",
115추가: "git_blob": "ed9af89904de5a4b44673b098e944b35faa3075f",
116추가: "mode": "100644",
117추가: "sha256": "88aa71907bfd07ef61697eb2c71e8ffbdc178c68ea9fcae8d26957be4751fa21"
118추가: },
119추가: {
120추가: "path": "experiments/rust-gzip-file-job/Cargo.lock",
121추가: "git_blob": "ac727b854d6d077e6e82cd6f2a6ec8687fb90a0a",
122추가: "mode": "100644",
123추가: "sha256": "a7c66f4a02cbae817a7147ce4c08d0b9a53e0e94b38fc6e66352bbd9b7709629"
124추가: },
125추가: {
126추가: "path": "experiments/rust-gzip-file-job/Cargo.toml",
127추가: "git_blob": "e8b16d664942b3f6782e0daa27d3965eabfa7716",
128추가: "mode": "100644",
129추가: "sha256": "0a994efa506a648fdad3615a944f1d78c83ef2f5a23a6b2420e5e9dfaeb5e65c"
130추가: },
131추가: {
132추가: "path": "experiments/rust-gzip-file-job/LICENSE",
133추가: "git_blob": "5014abac33298592fd3450b51a9b414191e1aabc",
134추가: "mode": "100644",
135추가: "sha256": "0714945e52a4d5b560c02c9a18478519f8c4e2572cbf87bd6d52adcfb2b63c62"
136추가: },
137추가: {
138추가: "path": "experiments/rust-gzip-file-job/SHA256SUMS",
139추가: "git_blob": "c7ac5be9104abbe123d3cd66762a3f046dade0f0",
140추가: "mode": "100644",
141추가: "sha256": "ef32ad5306d2d98751836846f631f66c562e4b55caf5d3422e120305aa78b37f"
142추가: },
143추가: {
144추가: "path": "experiments/rust-gzip-file-job/THIRD-PARTY-NOTICES.txt",
145추가: "git_blob": "93ab1f0bd590597015c867ce9ee7dee5a01b1a1d",
146추가: "mode": "100644",
147추가: "sha256": "3e2e572d0aa960ae002b6cdf3fb68008323d1e50b014d6ae2d3adf1845e7a3c3"
148추가: },
149추가: {
150추가: "path": "experiments/rust-gzip-file-job/contract.json",
151추가: "git_blob": "f1f7ec8d84b644486d46e084dd64509f7e1925ce",
152추가: "mode": "100644",
153추가: "sha256": "2b617a3792b520c421d4ac8f6dd8e95de7425303a3d8b134200419a8de07ba45"
154추가: },
155추가: {
156추가: "path": "experiments/rust-gzip-file-job/dependencies.json",
157추가: "git_blob": "552885ea312260dc2e289366f14407c605e3c8d9",
158추가: "mode": "100644",
159추가: "sha256": "52cfbf2e1363b604dc52b1a343b8f76589e920b71f1ac7564a7e413a0d3fe40d"
160추가: },
161추가: {
162추가: "path": "experiments/rust-gzip-file-job/source-pins.json",
163추가: "git_blob": "a080b5d20ca65f1f8d14d6321faa626fe8ac5217",
164추가: "mode": "100644",
165추가: "sha256": "01d5b0afef63b979c04fdcc6e7077915f00982dbfc44e3cbc84899c619c5c7d9"
166추가: },
167추가: {
168추가: "path": "experiments/rust-gzip-file-job/src/lib.rs",
169추가: "git_blob": "e7f1ee35efb71a1022c52a2e2e44b35780ae98e4",
170추가: "mode": "100644",
171추가: "sha256": "dad3309af8706359c1c34e6e1f56d5eb5f4ddf7f101d81f4621bbf9772592b45"
172추가: },
173추가: {
174추가: "path": "experiments/rust-gzip-file-job/src/types.rs",
175추가: "git_blob": "58f1966f7b9b20a15a27cdc11ac217fbfd1ab9e5",
176추가: "mode": "100644",
177추가: "sha256": "07f98df13fe48edeef5a23905a2cb9c1d257066e97c7d413cd06a754d44b7b4b"
178추가: },
179추가: {
180추가: "path": "experiments/rust-gzip-file-job/static-validation.json",
181추가: "git_blob": "8ba55e6b262a3fb2677bac8a022e3583f08b914f",
182추가: "mode": "100644",
183추가: "sha256": "274a8fb2ea9991633856fdda6802044e409bffe325af09372fa18e85e684b10c"
184추가: },
185추가: {
186추가: "path": "experiments/rust-memory-gzip-reader/Cargo.lock",
187추가: "git_blob": "a638f9b00ea1d76a99ccd93ea465ef9df4163c7a",
188추가: "mode": "100644",
189추가: "sha256": "511197f27b89d37c86f82ae1e8dda4229a3e5082ede9274efe8480df6e650d24"
190추가: },
191추가: {
192추가: "path": "experiments/rust-memory-gzip-reader/Cargo.toml",
193추가: "git_blob": "1b1b77e23d39cde1f05e55f73b62f68cf77dd9c6",
194추가: "mode": "100644",
195추가: "sha256": "ae76aededbb85cdd6c9227b4c06a1c8fef1bb7f203f1703e787b68f30ccfab6a"
196추가: },
197추가: {
198추가: "path": "experiments/rust-memory-gzip-reader/LICENSE",
199추가: "git_blob": "5014abac33298592fd3450b51a9b414191e1aabc",
200추가: "mode": "100644",
201추가: "sha256": "0714945e52a4d5b560c02c9a18478519f8c4e2572cbf87bd6d52adcfb2b63c62"
202추가: },
203추가: {
204추가: "path": "experiments/rust-memory-gzip-reader/SHA256SUMS",
205추가: "git_blob": "e248c4827c2fb2e82a5e92f80deb0d744209c65c",
206추가: "mode": "100644",
207추가: "sha256": "13e41e7d8ce2442cd8d93b1229211a5257e0568acc3466d5f9ec37f03c72a736"
208추가: },
209추가: {
210추가: "path": "experiments/rust-memory-gzip-reader/THIRD-PARTY-NOTICES.txt",
211추가: "git_blob": "f56aa8d736e78465701ac62fa5ad26d4d7dc05c9",
212추가: "mode": "100644",
213추가: "sha256": "655ad3bee8c41a593c2b00cbb0a12be11e7246c41dda00319c223dd3f904910e"
214추가: },
215추가: {
216추가: "path": "experiments/rust-memory-gzip-reader/contract.json",
217추가: "git_blob": "02729ca349d5629b1a9fcd7040441db2e2660065",
218추가: "mode": "100644",
219추가: "sha256": "1346c0b6f0ce5221acb9aef5067b0169e08ea6752f4db41a8b9c36b10ef9b43b"
220추가: },
221추가: {
222추가: "path": "experiments/rust-memory-gzip-reader/dependencies.json",
223추가: "git_blob": "bf9da9b737d9d574d5e31fb8343f844b61e4c192",
224추가: "mode": "100644",
225추가: "sha256": "3f71220451f8cd55dafdb6e6ae901572ec7bbe1be9c93d78953b44244aec6b07"
226추가: },
227추가: {
228추가: "path": "experiments/rust-memory-gzip-reader/src/budget.rs",
229추가: "git_blob": "0fa6fd1cdb541896540b7003168e5db71c11cb4b",
230추가: "mode": "100644",
231추가: "sha256": "b0d0b891a048712baba2038b8439d809a0359638f390b806f88496733753d61c"
232추가: },
233추가: {
234추가: "path": "experiments/rust-memory-gzip-reader/src/lib.rs",
235추가: "git_blob": "1811dfc7ec0917da607727e7942b5a268ac7330a",
236추가: "mode": "100644",
237추가: "sha256": "a865a114fdb9d79b66226387b9f0e3fa601aad29cfe65ab443c946d6cbd74062"
238추가: }
239추가: ]
240추가: }
추가tests/rust-gzip-file-job/static_check.py+157-0
@@ -0,0 +1,157 @@
1추가: import argparse
2추가: import hashlib
3추가: import json
4추가: import pathlib
5추가: import re
6추가: import stat
7추가: import sys
8추가: import tomllib
9추가:
10추가: BASE = pathlib.Path(__file__).resolve().parent
11추가: ROOT = BASE.parents[1]
12추가: SOURCE = ROOT / "experiments/rust-gzip-file-job"
13추가: HEAD = "4c6ae4b3a7ab12a992598e94e7b02f3a167fbbd4"
14추가: TREE = "9a01a37623b163c35ca4ff25963b2e11c61a0c35"
15추가: SOURCE_MANIFEST = "ef32ad5306d2d98751836846f631f66c562e4b55caf5d3422e120305aa78b37f"
16추가: MODULES = ("success", "invalid", "limits", "control", "namespace", "concurrency")
17추가: FILES = {
18추가: "Cargo.toml", "Cargo.lock", "main.rs", "support.rs", "fixtures.rs",
19추가: "success.rs", "invalid.rs", "limits.rs", "control.rs", "namespace.rs", "concurrency.rs",
20추가: "source-pins.json", "contract.json", "run-plan.json", "static_check.py",
21추가: "static_check_helper_tests.py",
22추가: }
23추가: GUARD = "최적화 모드에서는 정적 검사를 실행할 수 없음"
24추가:
25추가:
26추가: def require(condition, message):
27추가: if not condition:
28추가: raise RuntimeError(message)
29추가:
30추가:
31추가: def digest(raw):
32추가: return hashlib.sha256(raw).hexdigest()
33추가:
34추가:
35추가: def parse_manifest(text, expected_paths):
36추가: rows = {}
37추가: for line in text.splitlines():
38추가: match = re.fullmatch(r"([0-9a-f]{64}) ([A-Za-z0-9_./-]+)", line)
39추가: require(match is not None, "잘못된 manifest 행")
40추가: value, name = match.groups()
41추가: path = pathlib.PurePosixPath(name)
42추가: require(not path.is_absolute() and ".." not in path.parts
43추가: and str(path) == name and name not in rows, "중복 또는 잘못된 경로")
44추가: rows[name] = value
45추가: require(set(rows) == set(expected_paths), "manifest 경로 불일치")
46추가: return rows
47추가:
48추가:
49추가: def hashes():
50추가: result = {}
51추가: for name in sorted(FILES | {"SHA256SUMS"}):
52추가: path = BASE / name
53추가: require(path.resolve() == path and stat.S_ISREG(path.lstat().st_mode), "일반 시험 파일 필요")
54추가: require(not path.stat().st_mode & 0o111, "시험 파일 mode 불일치")
55추가: result[name] = digest(path.read_bytes())
56추가: return result
57추가:
58추가:
59추가: def verify_sources():
60추가: pins = json.loads((BASE / "source-pins.json").read_text())
61추가: require(pins["head"] == HEAD and pins["tree"] == TREE and len(pins["files"]) == 39, "고정 source 기준 불일치")
62추가: require(len({row["path"] for row in pins["files"]}) == 39, "source 경로 중복")
63추가: roots = ("experiments/rust-gzip-file-job/", "experiments/rust-file-snapshot/",
64추가: "experiments/rust-file-publication/", "experiments/rust-memory-gzip-reader/")
65추가: result = {}
66추가: for row in pins["files"]:
67추가: path = ROOT / row["path"]
68추가: require(row["path"].startswith(roots) and path.resolve() == path, "source 경로 이탈")
69추가: info = path.lstat()
70추가: require(stat.S_ISREG(info.st_mode) and not info.st_mode & 0o111, "source mode 불일치")
71추가: raw = path.read_bytes()
72추가: require(digest(raw) == row["sha256"], "source SHA256 불일치")
73추가: blob = hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest()
74추가: require(blob == row["git_blob"] and row["mode"] == "100644", "source blob 불일치")
75추가: result[row["path"]] = digest(raw)
76추가: require(digest((SOURCE / "SHA256SUMS").read_bytes()) == SOURCE_MANIFEST, "source manifest 불일치")
77추가: return result
78추가:
79추가:
80추가: def main():
81추가: if sys.flags.optimize:
82추가: raise RuntimeError(GUARD)
83추가: parser = argparse.ArgumentParser()
84추가: parser.add_argument("--manifest-sha256", required=True)
85추가: parser.add_argument("--metadata", type=pathlib.Path)
86추가: args = parser.parse_args()
87추가: before = hashes()
88추가: require(before["SHA256SUMS"] == args.manifest_sha256, "시험 manifest 불일치")
89추가: rows = parse_manifest((BASE / "SHA256SUMS").read_text(), FILES)
90추가: require(all(before[name] == value for name, value in rows.items()), "시험 파일 변경")
91추가: sources = verify_sources()
92추가: contract = json.loads((BASE / "contract.json").read_text())
93추가: require(contract["source_head"] == HEAD and contract["source_tree"] == TREE, "계약 head 불일치")
94추가: require(contract["source_manifest_sha256"] == SOURCE_MANIFEST, "계약 manifest 불일치")
95추가: require(set(contract["deliverables"]) == FILES | {"SHA256SUMS"}, "배포 파일 집합 불일치")
96추가: names = []
97추가: for module in MODULES:
98추가: text = (BASE / (module + ".rs")).read_text()
99추가: found = re.findall(r"#\[test\]\s*fn ([a-z0-9_]+)\(", text)
100추가: require(len(found) == text.count("#[test]"), "시험 선언 분석 실패")
101추가: names.extend(module + "::" + name for name in found)
102추가: require(len(names) == len(set(names)) == contract["declared_test_count"] == 62, "선언 수 불일치")
103추가: require(sorted(names) == contract["test_names"] == sorted(contract["evidence_classes"]), "이름 집합 불일치")
104추가: for name in FILES:
105추가: raw = (BASE / name).read_bytes()
106추가: require(b"\xc2\xb7" not in raw, "가운뎃점 금지")
107추가: for path in BASE.glob("*.rs"):
108추가: text = path.read_text()
109추가: require("#[ignore" not in text and "#[should_panic" not in text, "시험 제외 금지")
110추가: require(not re.search(r"include!|#\[path|Command::|execveat|\bchmod\b|\bchown\b|\bmount\b", text), "범위 밖 Rust 경계")
111추가: support = (BASE / "support.rs").read_text()
112추가: require("impl Drop for Sandbox" not in support, "실패 증거 자동 정리 금지")
113추가: require("owned_descriptors(&self.root).is_empty()" in support, "소유 fd 점검 누락")
114추가: main = (BASE / "main.rs").read_text()
115추가: require(main.startswith('#![cfg(target_os = "linux")]'), "native Linux 경계 누락")
116추가: require(set(re.findall(r"mod ([a-z_]+);", main)) == set(MODULES) | {"support", "fixtures"}, "모듈 집합 불일치")
117추가: plan = json.loads((BASE / "run-plan.json").read_text())
118추가: require(plan["target"]["exact_names"] == sorted(names) and plan["target"]["count"] == 62, "실행 계획 이름 불일치")
119추가: require(plan["target"]["filtered_per_case"] == 61, "filtered 수 불일치")
120추가: require(plan["bounds"]["per_case_seconds"] == 30 and plan["bounds"]["channel_wait_seconds"] == 5, "시간 상한 변경")
121추가: require(plan["bounds"]["compile_seconds"] == 120 and plan["bounds"]["per_command_log_bytes"] == 8388608, "실행 상한 변경")
122추가: manifest = tomllib.loads((BASE / "Cargo.toml").read_text())
123추가: require(manifest["package"]["autotests"] is False, "자동 시험 발견 금지")
124추가: require(manifest["test"] == [{"name": "file_job_public_api", "path": "main.rs"}], "target 불일치")
125추가: require(manifest["dependencies"] == {
126추가: "job": {"package": "zipelo-gzip-file-job", "path": "../../experiments/rust-gzip-file-job"},
127추가: "libc": {"version": "=0.2.191", "default-features": False, "features": ["std"]},
128추가: "sha2": {"version": "=0.10.9", "default-features": False, "features": ["std", "force-soft"]},
129추가: }, "직접 의존성 변경")
130추가: normal = lambda rows: sorted(rows, key=lambda row: (row["name"], row["version"]))
131추가: original = tomllib.loads((SOURCE / "Cargo.lock").read_text())["package"]
132추가: locked = tomllib.loads((BASE / "Cargo.lock").read_text())["package"]
133추가: package = {"name": "zipelo-gzip-file-job-regressions", "version": "0.1.0",
134추가: "dependencies": ["libc", "sha2", "zipelo-gzip-file-job"]}
135추가: require(normal(locked) == normal(original + [package]), "기존 lock graph 변경")
136추가: require(len([p for p in locked if "source" in p]) == 11, "registry 수 변경")
137추가: if args.metadata:
138추가: require(args.metadata.resolve().is_relative_to(BASE), "metadata 위치 이탈")
139추가: metadata = json.loads(args.metadata.read_text())
140추가: packages = {p["id"]: p for p in metadata["packages"]}
141추가: root = packages[metadata["resolve"]["root"]]
142추가: require(root["name"] == package["name"], "metadata root 불일치")
143추가: require(len(root["targets"]) == 1 and root["targets"][0]["kind"] == ["test"], "target 추가")
144추가: require(pathlib.Path(root["targets"][0]["src_path"]) == BASE / "main.rs", "시험 경로 이탈")
145추가: for node in metadata["resolve"]["nodes"]:
146추가: name = packages[node["id"]]["name"]
147추가: if name == "sha2":
148추가: require(sorted(node["features"]) == ["force-soft", "std"], "sha2 feature 변경")
149추가: if name == "libc":
150추가: require(sorted(node["features"]) == ["std"], "libc feature 변경")
151추가: require(verify_sources() == sources and hashes() == before, "검사 중 입력 변경")
152추가: print(json.dumps({"head": HEAD, "source_files": 39, "declared": len(names),
153추가: "rust_compiled": False, "rust_executed": 0, "inputs_unchanged": True}))
154추가:
155추가:
156추가: if __name__ == "__main__":
157추가: main()
추가tests/rust-gzip-file-job/static_check_helper_tests.py+102-0
@@ -0,0 +1,102 @@
1추가: import json
2추가: import os
3추가: import pathlib
4추가: import runpy
5추가: import subprocess
6추가: import sys
7추가: import unittest
8추가:
9추가: BASE = pathlib.Path(__file__).resolve().parent
10추가: CHECKER = BASE / "static_check.py"
11추가: CODE = """
12추가: import json, pathlib, runpy, sys
13추가: from unittest.mock import patch
14추가: scope = runpy.run_path(sys.argv[1])
15추가: calls = []
16추가: def blocked(*args, **kwargs):
17추가: calls.append("side_effect")
18추가: raise RuntimeError("side_effect")
19추가: with patch("argparse.ArgumentParser", blocked), \
20추가: patch.object(pathlib.Path, "read_bytes", blocked), \
21추가: patch.object(pathlib.Path, "read_text", blocked), \
22추가: patch.object(runpy, "run_path", blocked):
23추가: try:
24추가: scope["main"]()
25추가: except RuntimeError as error:
26추가: print(json.dumps({"message": str(error), "calls": calls, "optimize": sys.flags.optimize}))
27추가: """
28추가:
29추가:
30추가: class StaticHelperTests(unittest.TestCase):
31추가: def child(self, environment_mode=False, flag=False, cli=False):
32추가: environment = os.environ.copy()
33추가: environment.pop("PYTHONOPTIMIZE", None)
34추가: environment["PYTHONDONTWRITEBYTECODE"] = "1"
35추가: if environment_mode:
36추가: environment["PYTHONOPTIMIZE"] = "1"
37추가: command = [sys.executable, "-B"] + (["-O"] if flag else [])
38추가: command += [str(CHECKER)] if cli else ["-c", CODE, str(CHECKER)]
39추가: return subprocess.run(command, env=environment, cwd=BASE,
40추가: capture_output=True, text=True, timeout=10)
41추가:
42추가: def probe(self, **mode):
43추가: result = self.child(**mode)
44추가: self.assertEqual(result.returncode, 0, result.stderr)
45추가: self.assertEqual(result.stderr, "")
46추가: self.assertEqual(json.loads(result.stdout), {
47추가: "message": "최적화 모드에서는 정적 검사를 실행할 수 없음",
48추가: "calls": [], "optimize": 1,
49추가: })
50추가:
51추가: def test_flag_stops_before_reads_arguments_and_generation(self):
52추가: self.probe(flag=True)
53추가:
54추가: def test_environment_stops_before_reads_arguments_and_generation(self):
55추가: self.probe(environment_mode=True)
56추가:
57추가: def test_normal_mode_reaches_parser(self):
58추가: result = self.child()
59추가: self.assertEqual(result.returncode, 0, result.stderr)
60추가: self.assertEqual(json.loads(result.stdout), {
61추가: "message": "side_effect", "calls": ["side_effect"], "optimize": 0,
62추가: })
63추가:
64추가: def test_flag_cli_fails_before_required_arguments(self):
65추가: result = self.child(flag=True, cli=True)
66추가: self.assertNotEqual(result.returncode, 0)
67추가: self.assertEqual(result.stdout, "")
68추가: self.assertIn("RuntimeError: 최적화 모드", result.stderr)
69추가: self.assertNotIn("arguments are required", result.stderr)
70추가:
71추가: def test_environment_cli_fails_before_required_arguments(self):
72추가: result = self.child(environment_mode=True, cli=True)
73추가: self.assertNotEqual(result.returncode, 0)
74추가: self.assertEqual(result.stdout, "")
75추가: self.assertIn("RuntimeError: 최적화 모드", result.stderr)
76추가:
77추가: def reject(self, content, paths):
78추가: parse = runpy.run_path(str(CHECKER))["parse_manifest"]
79추가: with self.assertRaises(RuntimeError):
80추가: parse(content, paths)
81추가:
82추가: def test_duplicate_manifest_rows_rejected(self):
83추가: line = "a" * 64 + " main.rs\n"
84추가: self.reject(line + line, {"main.rs"})
85추가:
86추가: def test_missing_manifest_path_rejected(self):
87추가: self.reject("a" * 64 + " main.rs\n", {"main.rs", "support.rs"})
88추가:
89추가: def test_parent_path_rejected(self):
90추가: self.reject("a" * 64 + " ../main.rs\n", {"../main.rs"})
91추가:
92추가: def test_repository_relative_source_manifest_path(self):
93추가: parse = runpy.run_path(str(CHECKER))["parse_manifest"]
94추가: name = "experiments/rust-file-publication/src/lib.rs"
95추가: self.assertEqual(parse("a" * 64 + " " + name + "\n", {name}), {name: "a" * 64})
96추가:
97추가: def test_malformed_digest_rejected(self):
98추가: self.reject("g" * 64 + " main.rs\n", {"main.rs"})
99추가:
100추가:
101추가: if __name__ == "__main__":
102추가: unittest.main(verbosity=2)
추가tests/rust-gzip-file-job/success.rs+105-0
@@ -0,0 +1,105 @@
1추가: use crate::{fixtures::*, support::*};
2추가: use job::{Event, FileJob, Limits, Stop, gzip, publication};
3추가: use std::fs;
4추가:
5추가: fn boundary(length: usize) {
6추가: let sandbox = Sandbox::new();
7추가: let bytes = pattern(length);
8추가: let archive = stored(&bytes);
9추가: let input = sandbox.file("input.gz", &archive);
10추가: let before = identity(&input);
11추가: let parent = sandbox.parent();
12추가: let (report, trace) = run(&input, &parent, Limits::default());
13추가: observations(&report, (before.0, before.1), &archive, &bytes, 10);
14추가: committed(&report, &parent, &bytes);
15추가: assert_eq!(identity(&input), before);
16추가: assert_eq!(fs::read(&input).unwrap(), archive);
17추가: assert!(
18추가: matches!(trace.points.last().unwrap().event, Event::Publication(point) if point.stage == publication::Stage::BeforeCommit)
19추가: );
20추가: assert!(owned_descriptors(&sandbox.root).is_empty());
21추가: sandbox.finish();
22추가: }
23추가:
24추가: #[test]
25추가: fn empty_output() {
26추가: boundary(0);
27추가: }
28추가: #[test]
29추가: fn one_byte_output() {
30추가: boundary(1);
31추가: }
32추가: #[test]
33추가: fn known_bytes_output() {
34추가: boundary(3);
35추가: }
36추가: #[test]
37추가: fn chunk_minus_one_output() {
38추가: boundary(65_535);
39추가: }
40추가: #[test]
41추가: fn chunk_output() {
42추가: boundary(65_536);
43추가: }
44추가: #[test]
45추가: fn chunk_plus_one_output() {
46추가: boundary(65_537);
47추가: }
48추가:
49추가: #[test]
50추가: fn header_name_and_comment_never_select_destination() {
51추가: let sandbox = Sandbox::new();
52추가: let bytes = b"abc";
53추가: assert_eq!(crc32(b"123456789"), 0xcbf4_3926);
54추가: let archive = named(bytes);
55추가: let header = 10 + b"../header-name\0../comment-name\0".len();
56추가: let input = sandbox.file("input.gz", &archive);
57추가: let before = identity(&input);
58추가: let parent = sandbox.parent();
59추가: let (report, _) = run(&input, &parent, Limits::default());
60추가: observations(&report, (before.0, before.1), &archive, bytes, header);
61추가: committed(&report, &parent, bytes);
62추가: assert_eq!(
63추가: names(&sandbox.root),
64추가: vec![
65추가: std::ffi::OsString::from("input.gz"),
66추가: std::ffi::OsString::from("parent")
67추가: ]
68추가: );
69추가: assert_eq!(identity(&input), before);
70추가: sandbox.finish();
71추가: }
72추가:
73추가: #[test]
74추가: fn replacing_input_after_snapshot_uses_captured_owned_bytes() {
75추가: let sandbox = Sandbox::new();
76추가: let archive = stored(b"original");
77추가: let replacement = stored(b"replacement");
78추가: let input = sandbox.file("input.gz", &archive);
79추가: let before = identity(&input);
80추가: let parent = sandbox.parent();
81추가: let (task, cancel) = FileJob::new();
82추가: let mut changed = false;
83추가: let mut trace = Trace::default();
84추가: let report = task.run(request(&input, &parent, Limits::default()), |point| {
85추가: trace.push(point);
86추가: if matches!(point.event, Event::Decode(native) if native.stage == gzip::Stage::Start) {
87추가: fs::rename(&input, sandbox.path("old.gz")).unwrap();
88추가: sandbox.file("input.gz", &replacement);
89추가: changed = true;
90추가: }
91추가: Ok::<_, Stop<()>>(())
92추가: });
93추가: assert!(changed);
94추가: trace.finish(&report);
95추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished);
96추가: observations(&report, (before.0, before.1), &archive, b"original", 10);
97추가: committed(&report, &parent, b"original");
98추가: assert_eq!(fs::read(&input).unwrap(), replacement);
99추가: assert_eq!(fs::read(sandbox.path("old.gz")).unwrap(), archive);
100추가: assert_ne!(
101추가: (identity(&input).0, identity(&input).1),
102추가: (before.0, before.1)
103추가: );
104추가: sandbox.finish();
105추가: }
추가tests/rust-gzip-file-job/support.rs+380-0
@@ -0,0 +1,380 @@
1추가: use crate::fixtures::crc32;
2추가: use job::{
3추가: Checkpoint, Event, FileJob, Limits, Outcome, Report, Request, Stop, Usage, gzip, publication,
4추가: snapshot,
5추가: };
6추가: use sha2::{Digest, Sha256};
7추가: use std::{
8추가: ffi::{OsStr, OsString},
9추가: fs::{self, DirBuilder, OpenOptions},
10추가: io::Write,
11추가: os::unix::fs::{DirBuilderExt, MetadataExt, OpenOptionsExt},
12추가: path::{Path, PathBuf},
13추가: sync::atomic::{AtomicU64, Ordering},
14추가: };
15추가:
16추가: static NEXT: AtomicU64 = AtomicU64::new(1);
17추가:
18추가: pub struct Sandbox {
19추가: pub root: PathBuf,
20추가: identity: (u64, u64),
21추가: }
22추가:
23추가: impl Sandbox {
24추가: pub fn new() -> Self {
25추가: let runs = Path::new(env!("CARGO_MANIFEST_DIR")).join("runs");
26추가: let info = fs::symlink_metadata(&runs).expect("runner가 전용 runs를 준비해야 함");
27추가: assert!(info.is_dir() && !info.file_type().is_symlink());
28추가: assert_eq!(info.mode() & 0o777, 0o700);
29추가: assert_eq!(info.uid(), unsafe { libc::geteuid() });
30추가: assert_eq!(runs.canonicalize().unwrap(), runs);
31추가: let root = runs.join(format!(
32추가: "case-{}-{}",
33추가: std::process::id(),
34추가: NEXT.fetch_add(1, Ordering::Relaxed)
35추가: ));
36추가: DirBuilder::new().mode(0o700).create(&root).unwrap();
37추가: let info = fs::symlink_metadata(&root).unwrap();
38추가: let result = Self {
39추가: root,
40추가: identity: (info.dev(), info.ino()),
41추가: };
42추가: result.dir("parent");
43추가: result
44추가: }
45추가:
46추가: pub fn path(&self, name: impl AsRef<Path>) -> PathBuf {
47추가: let name = name.as_ref();
48추가: assert!(
49추가: name.components()
50추가: .all(|part| matches!(part, std::path::Component::Normal(_)))
51추가: );
52추가: self.root.join(name)
53추가: }
54추가:
55추가: pub fn parent(&self) -> PathBuf {
56추가: self.path("parent")
57추가: }
58추가:
59추가: pub fn dir(&self, name: impl AsRef<Path>) -> PathBuf {
60추가: let path = self.path(name);
61추가: DirBuilder::new().mode(0o700).create(&path).unwrap();
62추가: path
63추가: }
64추가:
65추가: pub fn file(&self, name: impl AsRef<Path>, bytes: &[u8]) -> PathBuf {
66추가: let path = self.path(name);
67추가: let mut handle = OpenOptions::new()
68추가: .write(true)
69추가: .create_new(true)
70추가: .mode(0o600)
71추가: .open(&path)
72추가: .unwrap();
73추가: handle.write_all(bytes).unwrap();
74추가: handle.sync_all().unwrap();
75추가: path
76추가: }
77추가:
78추가: pub fn finish(self) {
79추가: assert!(
80추가: owned_descriptors(&self.root).is_empty(),
81추가: "소유 fd가 남아 있음"
82추가: );
83추가: let info = fs::symlink_metadata(&self.root).unwrap();
84추가: assert!(info.is_dir() && !info.file_type().is_symlink());
85추가: assert_eq!((info.dev(), info.ino()), self.identity);
86추가: fs::remove_dir_all(&self.root).unwrap();
87추가: assert!(!self.root.exists());
88추가: }
89추가: }
90추가:
91추가: pub fn owned_descriptors(root: &Path) -> Vec<u32> {
92추가: let mut result = Vec::new();
93추가: for item in fs::read_dir("/proc/self/fd").unwrap() {
94추가: let item = item.unwrap();
95추가: if let Ok(target) = fs::read_link(item.path()) {
96추가: if target.starts_with(root) {
97추가: result.push(item.file_name().to_str().unwrap().parse().unwrap());
98추가: }
99추가: }
100추가: }
101추가: result.sort();
102추가: result
103추가: }
104추가:
105추가: pub fn names(parent: &Path) -> Vec<OsString> {
106추가: let mut result: Vec<_> = fs::read_dir(parent)
107추가: .unwrap()
108추가: .map(|e| e.unwrap().file_name())
109추가: .collect();
110추가: result.sort();
111추가: result
112추가: }
113추가:
114추가: pub fn identity(path: &Path) -> (u64, u64, u64, u32, i64, i64, i64, i64) {
115추가: let m = fs::symlink_metadata(path).unwrap();
116추가: (
117추가: m.dev(),
118추가: m.ino(),
119추가: m.len(),
120추가: m.mode(),
121추가: m.mtime(),
122추가: m.mtime_nsec(),
123추가: m.ctime(),
124추가: m.ctime_nsec(),
125추가: )
126추가: }
127추가:
128추가: pub fn request<'a>(input: &'a Path, parent: &'a Path, limits: Limits) -> Request<'a> {
129추가: Request {
130추가: input,
131추가: output_parent: parent,
132추가: output_leaf: OsStr::new("output"),
133추가: limits,
134추가: }
135추가: }
136추가:
137추가: #[derive(Default)]
138추가: pub struct Trace {
139추가: pub points: Vec<Checkpoint>,
140추가: }
141추가:
142추가: fn counters(usage: Usage) -> [u64; 18] {
143추가: let s = usage.snapshot;
144추가: let g = usage.gzip;
145추가: let p = usage.publication;
146추가: [
147추가: s.open_calls,
148추가: s.metadata_calls,
149추가: s.read_calls,
150추가: s.reserved_read_bytes,
151추가: s.actual_read_bytes,
152추가: s.compared_bytes,
153추가: g.processed,
154추가: g.output,
155추가: g.metadata,
156추가: p.open_calls,
157추가: p.metadata_calls,
158추가: p.sync_calls,
159추가: p.link_calls,
160추가: p.read_calls,
161추가: p.write_calls,
162추가: p.reserved_io_bytes,
163추가: p.actual_read_bytes,
164추가: p.actual_written_bytes,
165추가: ]
166추가: }
167추가:
168추가: pub fn phase(event: Event) -> u8 {
169추가: match event {
170추가: Event::Snapshot(_) => 0,
171추가: Event::Decode(_) => 1,
172추가: Event::Publication(_) => 2,
173추가: }
174추가: }
175추가:
176추가: impl Trace {
177추가: pub fn push(&mut self, point: Checkpoint) {
178추가: if let Some(before) = self.points.last() {
179추가: assert!(phase(before.event) <= phase(point.event));
180추가: for (a, b) in counters(before.usage)
181추가: .into_iter()
182추가: .zip(counters(point.usage))
183추가: {
184추가: assert!(a <= b);
185추가: }
186추가: }
187추가: match point.event {
188추가: Event::Snapshot(native) => {
189추가: assert_eq!(point.usage.snapshot, native.usage);
190추가: assert_eq!(point.usage.gzip, gzip::Usage::default());
191추가: assert_eq!(point.usage.publication, publication::Usage::default());
192추가: }
193추가: Event::Decode(native) => {
194추가: assert_eq!(point.usage.gzip, native.usage);
195추가: assert_eq!(point.usage.publication, publication::Usage::default());
196추가: }
197추가: Event::Publication(native) => {
198추가: assert_eq!(point.usage.publication, native.usage);
199추가: assert_eq!(native.usage.link_calls, 0);
200추가: }
201추가: }
202추가: self.points.push(point);
203추가: }
204추가:
205추가: pub fn finish<E>(&self, report: &Report<E>) {
206추가: if let Some(last) = self.points.last() {
207추가: for (a, b) in counters(last.usage).into_iter().zip(counters(report.usage)) {
208추가: assert!(a <= b);
209추가: }
210추가: }
211추가: match &report.outcome {
212추가: Outcome::SnapshotFailed(failure) => {
213추가: assert_eq!(report.usage.snapshot, failure.usage);
214추가: assert_eq!(report.usage.gzip, gzip::Usage::default());
215추가: assert_eq!(report.usage.publication, publication::Usage::default());
216추가: assert!(report.snapshot.is_none() && report.decoded.is_none());
217추가: assert!(self.points.iter().all(|p| phase(p.event) == 0));
218추가: }
219추가: Outcome::DecodeFailed(_) => {
220추가: assert!(report.snapshot.is_some() && report.decoded.is_none());
221추가: assert_eq!(report.usage.publication, publication::Usage::default());
222추가: assert!(self.points.iter().all(|p| phase(p.event) <= 1));
223추가: }
224추가: Outcome::Publication(native) => {
225추가: assert!(report.snapshot.is_some() && report.decoded.is_some());
226추가: assert_eq!(report.usage.publication, native.usage);
227추가: }
228추가: Outcome::AdapterFailed(_) => panic!("정상 decoder에서 adapter 실패가 발생함"),
229추가: }
230추가: }
231추가: }
232추가:
233추가: pub fn run(input: &Path, parent: &Path, limits: Limits) -> (Report<()>, Trace) {
234추가: let (task, cancel) = FileJob::new();
235추가: let mut trace = Trace::default();
236추가: let report = task.run(request(input, parent, limits), |point| {
237추가: trace.push(point);
238추가: Ok::<_, Stop<()>>(())
239추가: });
240추가: trace.finish(&report);
241추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished);
242추가: (report, trace)
243추가: }
244추가:
245추가: pub fn snapshot_usage(usage: snapshot::Usage, length: usize) {
246추가: assert_eq!(
247추가: usage,
248추가: snapshot::Usage {
249추가: open_calls: 4,
250추가: metadata_calls: 5,
251추가: read_calls: 2 * (length as u64).div_ceil(65_536) + 2,
252추가: reserved_read_bytes: 2 * length as u64 + 2,
253추가: actual_read_bytes: 2 * length as u64,
254추가: compared_bytes: length as u64,
255추가: }
256추가: );
257추가: }
258추가:
259추가: pub fn gzip_usage(usage: gzip::Usage, archive: &[u8], output: &[u8], header: usize) {
260추가: assert_eq!(
261추가: usage,
262추가: gzip::Usage {
263추가: processed: (archive.len() + output.len()) as u64,
264추가: output: output.len() as u64,
265추가: metadata: header as u64,
266추가: }
267추가: );
268추가: }
269추가:
270추가: pub fn cleanup(value: &publication::Cleanup, attempts: u8) {
271추가: assert_eq!(value.attempted, attempts);
272추가: assert!(value.all_close_calls_succeeded());
273추가: assert!(value.failures.iter().all(Option::is_none));
274추가: }
275추가:
276추가: pub fn publication_usage(usage: publication::Usage, length: usize, linked: bool) {
277추가: let chunks = (length as u64).div_ceil(65_536);
278추가: assert_eq!(
279추가: usage,
280추가: publication::Usage {
281추가: open_calls: 4,
282추가: metadata_calls: 5,
283추가: sync_calls: if linked { 2 } else { 1 },
284추가: link_calls: 1,
285추가: read_calls: chunks + 1,
286추가: write_calls: chunks,
287추가: reserved_io_bytes: 2 * length as u64 + 1,
288추가: actual_read_bytes: length as u64,
289추가: actual_written_bytes: length as u64,
290추가: }
291추가: );
292추가: }
293추가:
294추가: pub fn observations<E>(
295추가: report: &Report<E>,
296추가: source_id: (u64, u64),
297추가: archive: &[u8],
298추가: output: &[u8],
299추가: header: usize,
300추가: ) {
301추가: let captured = report.snapshot.as_ref().expect("snapshot 관측값 누락");
302추가: assert_eq!(
303추가: (captured.identity().device(), captured.identity().inode()),
304추가: source_id
305추가: );
306추가: assert_eq!(captured.identity().length(), archive.len() as u64);
307추가: assert_eq!(captured.sha256(), <[u8; 32]>::from(Sha256::digest(archive)));
308추가: let boundary = report
309추가: .decoded
310추가: .as_ref()
311추가: .expect("decode 관측값 누락")
312추가: .boundary();
313추가: assert_eq!(boundary.header_bytes, header);
314추가: assert_eq!(boundary.member_bytes, archive.len());
315추가: assert_eq!(boundary.deflate_bytes as usize, archive.len() - header - 8);
316추가: assert_eq!(boundary.inflated_bytes, output.len() as u64);
317추가: assert_eq!(boundary.crc32, crc32(output));
318추가: snapshot_usage(report.usage.snapshot, archive.len());
319추가: gzip_usage(report.usage.gzip, archive, output, header);
320추가: }
321추가:
322추가: pub fn committed<E>(report: &Report<E>, parent: &Path, output: &[u8]) {
323추가: let native = match &report.outcome {
324추가: Outcome::Publication(native) => native,
325추가: _ => panic!("게시 보고서 누락"),
326추가: };
327추가: assert_eq!(native.usage, report.usage.publication);
328추가: publication_usage(native.usage, output.len(), true);
329추가: cleanup(&native.cleanup, 4);
330추가: let (receipt, durability) = match &native.outcome {
331추가: publication::Outcome::Committed {
332추가: receipt,
333추가: durability,
334추가: } => (receipt, durability),
335추가: _ => panic!("확정된 게시가 아님"),
336추가: };
337추가: assert!(matches!(
338추가: durability,
339추가: publication::Durability::FileAndParentSynced
340추가: ));
341추가: let m = fs::symlink_metadata(parent.join("output")).unwrap();
342추가: let p = fs::metadata(parent).unwrap();
343추가: assert!(m.is_file() && !m.file_type().is_symlink());
344추가: assert_eq!(m.nlink(), 1);
345추가: assert_eq!(m.mode() & 0o777, 0o600);
346추가: assert_eq!(receipt.length(), output.len() as u64);
347추가: assert_eq!(
348추가: (
349추가: receipt.parent_identity().device(),
350추가: receipt.parent_identity().inode()
351추가: ),
352추가: (p.dev(), p.ino())
353추가: );
354추가: assert_eq!(
355추가: (
356추가: receipt.file_identity().device(),
357추가: receipt.file_identity().inode()
358추가: ),
359추가: (m.dev(), m.ino())
360추가: );
361추가: assert_eq!(fs::read(parent.join("output")).unwrap(), output);
362추가: assert_eq!(names(parent), vec![OsString::from("output")]);
363추가: }
364추가:
365추가: pub fn conflict<E>(report: &Report<E>, length: usize) {
366추가: let native = match &report.outcome {
367추가: Outcome::Publication(native) => native,
368추가: _ => panic!("게시 보고서 누락"),
369추가: };
370추가: match &native.outcome {
371추가: publication::Outcome::NotCommitted(publication::Error::Io { operation, source }) => {
372추가: assert_eq!(*operation, "linkat_conflict");
373추가: assert_eq!(source.raw_os_error(), Some(libc::EEXIST));
374추가: }
375추가: _ => panic!("명확한 충돌 오류가 아님"),
376추가: }
377추가: assert_eq!(report.usage.publication, native.usage);
378추가: publication_usage(native.usage, length, false);
379추가: cleanup(&native.cleanup, 4);
380추가: }