원클릭으로
golden-test-management
Golden fixtures, snapshot tests, blessing workflows, mismatch triage, and volatile-field scrubbing.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Golden fixtures, snapshot tests, blessing workflows, mismatch triage, and volatile-field scrubbing.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use this skill to generate well-branded interfaces and assets for RIPDPI (an Android-native, Compose-first VPN and DPI-bypass app), either for production or throwaway prototypes/mocks/etc. Contains essential design guidelines, colors, type, fonts, brand-ship icons, and an interactive UI kit of every public composable from the live ui/components tree.
Use when managing the Rust workspace, adding/removing crates, editing workspace dependencies, running cargo nextest/audit/deny, configuring Cargo profiles for Android cross-compilation, debugging Cargo.lock churn, migrating crate edition, or wiring Gradle to cargo via the ripdpi.android.rust-native plugin.
Use when modifying the diagnostics scan pipeline, ScanRequest/ScanReport types, ProbeTask families, ripdpi-monitor-engine / ripdpi-diagnostics-* crates, strategy-probe candidates, the diagnostics catalog (packs/profiles), wire-schema contracts between Rust and Kotlin, DIAGNOSTICS_ENGINE_SCHEMA_VERSION, golden contract tests, or adding a new probe type / profile. Triggers on diagnostics scans, strategy probes, automatic audit, dpi-detector profiles, or anything in core/diagnostics or native/rust/crates/ripdpi-monitor-*.
Android-specific Rust build, verification, and packaging — per-target 16 KiB page alignment, size-optimized release profile, ELF symbol allowlist, .so size budgets, NDK 29 specifics. Use when modifying .cargo/config.toml for Android targets, the workspace [profile.release] / [profile.android-jni] block, or when verifying a built .so before release.
Telemetry and observability discipline for the RIPDPI Android Rust stack — control-plane vs data-plane logging, bounded flume event queues, atomic counters, snapshot polling, readiness callbacks, and deterministic JSON contracts. Use when authoring or modifying telemetry emission code, the bounded event ring, the Kotlin-side telemetry consumer, or any per-packet logging.
Custom detekt rules, DI/privacy/suppression guardrails, detekt.yml configuration, and false-positive triage.
| name | golden-test-management |
| description | Golden fixtures, snapshot tests, blessing workflows, mismatch triage, and volatile-field scrubbing. |
Golden contracts enforce compatibility for telemetry, diagnostics events, strategy-probe progress/report payloads, and exported data. Fixtures are read-only by default -- tests fail on unexpected diffs. Bless with RIPDPI_BLESS_GOLDENS=1 to update.
Full documentation: docs/testing.md (Golden contracts section).
| Layer | Location | Examples |
|---|---|---|
| Rust | native/rust/crates/{crate}/tests/golden/ | android-support, ripdpi-android, ripdpi-tunnel-android, ripdpi-monitor-engine |
| JVM | core/{module}/src/test/resources/golden/ | engine, service, diagnostics |
| Android instrumentation | app/src/androidTest/assets/golden/ | Copies of JVM fixtures for on-device smoke tests |
| Variable | Purpose | Default |
|---|---|---|
RIPDPI_BLESS_GOLDENS | Set to any value to write fixtures instead of comparing | Not set (read-only) |
RIPDPI_GOLDEN_ARTIFACT_DIR | Override diff artifact output directory | target/golden-diffs (Rust), build/golden-diffs/ (JVM) |
bash scripts/tests/bless-telemetry-goldens.sh
This script:
android-support, ripdpi-android, ripdpi-tunnel-android, ripdpi-monitor-engine)NativeTelemetryGoldenTest, ServiceTelemetryGoldenTest)app/src/androidTest/assets/golden/)# Rust
RIPDPI_BLESS_GOLDENS=1 cargo test --locked -p ripdpi-android --manifest-path native/rust/Cargo.toml
# Kotlin
RIPDPI_BLESS_GOLDENS=1 ./gradlew :core:engine:testDebugUnitTest --tests "*.NativeTelemetryGoldenTest"
git diff -- verify changes are intentionalOn mismatch, both Rust and JVM support libraries write three files:
| File | Content |
|---|---|
{name}.expected | The golden fixture content |
{name}.actual | What the test produced |
{name}.diff | Unified diff between expected and actual |
Rust: Written to target/golden-diffs/ (or RIPDPI_GOLDEN_ARTIFACT_DIR).
JVM: Written to {module}/build/golden-diffs/.
golden-test-support Crateuse golden_test_support::{assert_text_golden, canonicalize_json, canonicalize_json_with};
// Simple text comparison
assert_text_golden(env!("CARGO_MANIFEST_DIR"), "tests/golden/output.json", &actual);
// JSON with key sorting
let canonical = canonicalize_json(&json_string)?;
assert_text_golden(env!("CARGO_MANIFEST_DIR"), "tests/golden/data.json", &canonical);
// JSON with custom scrubbing
let canonical = canonicalize_json_with(&json_string, |value| {
// Remove volatile fields like timestamps
scrub_timestamps(value);
})?;
assert_text_golden(env!("CARGO_MANIFEST_DIR"), "tests/golden/data.json", &canonical);
GoldenContractSupport ObjectLocated in core/engine/src/test/kotlin/com/poyka/ripdpi/core/GoldenContractSupport.kt:
// JSON comparison with canonical key ordering
GoldenContractSupport.assertJsonGolden(
"snapshot.json",
json.encodeToString(serializer, data),
)
// JSON with custom scrubbing
GoldenContractSupport.assertJsonGolden(
"snapshot.json",
json.encodeToString(serializer, data),
::scrubVolatileFields, // (JsonElement) -> JsonElement
)
// Plain text comparison
GoldenContractSupport.assertTextGolden("output.txt", actualText)
Fields that change between runs must be scrubbed for deterministic comparison:
Scrubbed (non-deterministic):
serviceStartedAt, lastFailureAt, updatedAt, capturedAt, createdAt)Strict (must match exactly):
private fun scrubVolatileFields(value: JsonElement): JsonElement =
when (value) {
is JsonObject -> JsonObject(
value.mapValues { (key, element) ->
when (key) {
"serviceStartedAt", "lastFailureAt", "updatedAt",
"capturedAt", "createdAt" -> Json.parseToJsonElement("0")
else -> scrubVolatileFields(element)
}
},
)
else -> value
}
Add golden-test-support to [dev-dependencies] in the crate's Cargo.toml:
[dev-dependencies]
golden-test-support = { path = "../golden-test-support" }
Write the test:
#[test]
fn my_output_matches_golden() {
let actual = produce_output();
let canonical = canonicalize_json(&serde_json::to_string(&actual).unwrap()).unwrap();
assert_text_golden(env!("CARGO_MANIFEST_DIR"), "tests/golden/my_output.json", &canonical);
}
Create initial fixture: RIPDPI_BLESS_GOLDENS=1 cargo test --locked -p my-crate my_output_matches_golden
Review and commit the new fixture file.
Write the test using GoldenContractSupport:
@Test
fun myOutputMatchesGolden() {
val actual = produceOutput()
GoldenContractSupport.assertJsonGolden("my_output.json", jsonEncode(actual))
}
Create initial fixture: RIPDPI_BLESS_GOLDENS=1 ./gradlew :module:testDebugUnitTest --tests "*.MyGoldenTest"
Review and commit the new fixture file.
If the new golden is needed for Android instrumentation tests:
cp line to scripts/tests/bless-telemetry-goldens.shapp/src/androidTest/assets/golden/| Mistake | Fix |
|---|---|
| Blessing without reviewing diffs | Always git diff after blessing. Unexpected changes may indicate bugs. |
| Forgetting to scrub volatile fields | New timestamp/ID fields cause non-deterministic failures. Add to scrub function. |
| Not explaining golden changes in commit | Golden updates should always explain why the expected output changed. |
| Missing instrumentation sync | JVM fixture updated but app/src/androidTest/assets/golden/ not. Run bless script or add cp manually. |
Adding golden without canonicalize_json | JSON key order is non-deterministic. Always canonicalize before comparing. |
| Hardcoding fixture path | Rust: use env!("CARGO_MANIFEST_DIR"). Kotlin: GoldenContractSupport resolves repo root automatically. |
docs/testing.md -- Full test stack documentation including golden contracts sectionnative/rust/crates/golden-test-support/src/lib.rs -- Rust support library sourcecore/engine/src/test/kotlin/.../GoldenContractSupport.kt -- Kotlin support library sourcescripts/tests/bless-telemetry-goldens.sh -- Blessing script