fix(import): единая идентичность внешних URI (#96)
CI / Rust Checks (push) Successful in 25m54s
CI / UI Checks (push) Successful in 5s
CI / Community Image Smoke (push) Successful in 1m47s
CI / Frontend E2E (push) Successful in 10m12s
CI / Deploy (push) Successful in 1m22s

Единая transport-canonical идентичность внешних документов; normalizer v6 с immutable historical replay; matrix 1.0.4 / corpus 1.0.5. PR CI run840 success, локальная приёмка и independent review выполнены.

Co-authored-by: bsodfather <bsodfather@gmail.com>
This commit was merged in pull request #96.
This commit is contained in:
bsodfather authored and bsodfather committed 2026-10-11 06:19:16 +00:00
1 parent 178093e81b
commit 1b6db09bd1
22 files changed
+1669 -353

No files matched your search

+88 -61
View File
@@ -31,7 +31,7 @@ fn ac_1_support_matrix_rows_have_exact_construct_contracts() {
let matrix_text = fs::read_to_string(tests_root().join("support-matrix.yaml"))
.expect("support matrix exists");
let matrix: serde_yaml::Value = serde_yaml::from_str(&matrix_text).expect("valid YAML");
assert_eq!(matrix["matrix_version"].as_str(), Some("1.0.3"));
assert_eq!(matrix["matrix_version"].as_str(), Some("1.0.4"));
assert!(
matrix["compatibility_impact"]
.as_str()
@@ -696,73 +696,100 @@ fn ac_1_support_matrix_rows_have_exact_construct_contracts() {
row["specification_version"] == version && row["construct_id"] == construct
})
.unwrap();
let reference = if external {
"https://schemas.example.test/root.yaml#/Item"
} else if version == "Swagger 2.0" {
// The allowlisted-external row must exercise the same transport
// canonicalization the materializer keys snapshots with. The
// expected keys below are static literals, independent of the
// production `canonical_external_document_uri` helper: a
// percent-encoded dot segment collapses to its parent path and an
// apostrophe in the query is percent-encoded (`%27`).
let external_document = "Item: { type: object, properties: { id: { type: string } } }";
let external_variants: [(&str, &str); 3] = [
(
"https://schemas.example.test/root.yaml#/Item",
"https://schemas.example.test/root.yaml",
),
(
"https://schemas.example.test/a/%2e%2e/root.yaml#/Item",
"https://schemas.example.test/root.yaml",
),
(
"https://schemas.example.test/schema.json?filter='x'#/Item",
"https://schemas.example.test/schema.json?filter=%27x%27",
),
];
let local_reference = if version == "Swagger 2.0" {
"#/definitions/Item"
} else {
"#/components/schemas/Item"
};
let schema = json!({"$ref":reference});
let response = if version == "Swagger 2.0" {
json!({"description":"ok","schema":schema})
let variants = if external {
external_variants
.iter()
.map(|(reference, canonical_uri)| (*reference, Some(*canonical_uri)))
.collect::<Vec<_>>()
} else {
json!({"description":"ok","content":{"application/json":{"schema":schema}}})
vec![(local_reference, None)]
};
let probe = if version == "Swagger 2.0" {
let mut root = json!({"swagger":"2.0","info":{"title":"Reference probe","version":"1"},"paths":{"/probe":{"get":{"operationId":"referenceProbe","responses":{"200":response}}}}});
if !external {
root["definitions"] =
json!({"Item":{"type":"object","properties":{"id":{"type":"string"}}}});
}
root
} else {
let mut root = json!({"openapi":if version == "OpenAPI 3.0" {"3.0.3"} else {"3.1.0"},
"info":{"title":"Reference probe","version":"1"},"servers":[{"url":"https://matrix.example.test"}],"paths":{"/probe":{"get":{"operationId":"referenceProbe","responses":{"200":response}}}}});
if !external {
root["components"] = json!({"schemas":{"Item":{"type":"object","properties":{"id":{"type":"string"}}}}});
}
root
};
let source = serde_json::to_string(&probe).unwrap();
let ir = if external {
let external_source =
"Item: { type: object, properties: { id: { type: string } } }";
let snapshot = crank_import::rest::ExternalDocumentSnapshot {
canonical_uri: "https://schemas.example.test/root.yaml".to_owned(),
digest: SourceDigest::parse(hex(external_source.as_bytes())).unwrap(),
document: external_source.to_owned(),
for (reference, canonical_uri) in variants {
let schema = json!({"$ref":reference});
let response = if version == "Swagger 2.0" {
json!({"description":"ok","schema":schema})
} else {
json!({"description":"ok","content":{"application/json":{"schema":schema}}})
};
let digest = SourceDigest::parse(hex(source.as_bytes())).unwrap();
normalize_verified_bundle(
&source,
digest,
&[snapshot],
&NormalizationConfig::default(),
)
.unwrap()
} else {
normalize(&source).unwrap()
};
validate_normalized_ir(&ir).unwrap();
assert_eq!(row["status"], "supported");
assert!(
!ir.reference_graph.edges.is_empty(),
"{version} {construct} did not resolve through a source-backed edge"
);
assert!(
ir.unresolved_references.is_empty(),
"{version} {construct} remains unresolved"
);
assert!(
matches!(
ir.operations[0].response_variants[0].schema.as_ref().map(|schema| &schema.kind),
Some(NormalizedSchemaKind::Object { properties, .. }) if properties.contains_key("id")
),
"{version} {construct} resolved schema was not projected into the operation"
);
assert_actionable(&ir, &format!("{version} {construct}"));
assert_eq!(row["expected_finding"], "none");
let probe = if version == "Swagger 2.0" {
let mut root = json!({"swagger":"2.0","info":{"title":"Reference probe","version":"1"},"paths":{"/probe":{"get":{"operationId":"referenceProbe","responses":{"200":response}}}}});
if !external {
root["definitions"] =
json!({"Item":{"type":"object","properties":{"id":{"type":"string"}}}});
}
root
} else {
let mut root = json!({"openapi":if version == "OpenAPI 3.0" {"3.0.3"} else {"3.1.0"},
"info":{"title":"Reference probe","version":"1"},"servers":[{"url":"https://matrix.example.test"}],"paths":{"/probe":{"get":{"operationId":"referenceProbe","responses":{"200":response}}}}});
if !external {
root["components"] = json!({"schemas":{"Item":{"type":"object","properties":{"id":{"type":"string"}}}}});
}
root
};
let source = serde_json::to_string(&probe).unwrap();
let ir = if let Some(canonical_uri) = canonical_uri {
let snapshot = crank_import::rest::ExternalDocumentSnapshot {
canonical_uri: canonical_uri.to_owned(),
digest: SourceDigest::parse(hex(external_document.as_bytes())).unwrap(),
document: external_document.to_owned(),
};
let digest = SourceDigest::parse(hex(source.as_bytes())).unwrap();
normalize_verified_bundle(
&source,
digest,
&[snapshot],
&NormalizationConfig::default(),
)
.unwrap()
} else {
normalize(&source).unwrap()
};
validate_normalized_ir(&ir).unwrap();
assert_eq!(row["status"], "supported");
assert!(
!ir.reference_graph.edges.is_empty(),
"{version} {construct} did not resolve through a source-backed edge ({reference})"
);
assert!(
ir.unresolved_references.is_empty(),
"{version} {construct} remains unresolved ({reference})"
);
assert!(
matches!(
ir.operations[0].response_variants[0].schema.as_ref().map(|schema| &schema.kind),
Some(NormalizedSchemaKind::Object { properties, .. }) if properties.contains_key("id")
),
"{version} {construct} resolved schema was not projected into the operation ({reference})"
);
assert_actionable(&ir, &format!("{version} {construct} {reference}"));
assert_eq!(row["expected_finding"], "none");
}
probed(construct);
}
for code in 200..300 {