test(deploy): seal zone v2 consumer policy artifact

This commit is contained in:
Codex
2026-07-21 15:21:00 +03:00
parent 358b259aac
commit 45884cd4dc
2 changed files with 114 additions and 20 deletions
@@ -12,7 +12,7 @@ const platformRoot = resolve(scriptDir, "../..");
const workspaceRoot = resolve(platformRoot, "..");
const foundryRoot = resolve(workspaceRoot, "NODEDC_DESIGN_GUIDELINE");
const artifactDir = resolve(process.env.NODEDC_DEPLOY_ARTIFACT_DIR || resolve(scriptDir, "../deploy-artifacts"));
const [patchId = "module-foundry-consumer-policy-v4-20260720-001", ...extra] = process.argv.slice(2);
const [patchId = "module-foundry-zone-v2-consumer-policy-20260721-001", ...extra] = process.argv.slice(2);
if (extra.length || !/^[A-Za-z0-9._-]{1,96}$/.test(patchId)) {
throw new Error("patch_id_must_contain_only_letters_digits_dot_underscore_hyphen");
@@ -66,35 +66,84 @@ async function assertConsumerPolicyBoundary() {
if (registry?.schemaVersion !== "nodedc.foundry.data-product-consumer-policies/v1") {
throw new Error("foundry_consumer_policy_registry_invalid");
}
const matches = registry.policies?.filter((policy) => (
const movingObjectV4Matches = registry.policies?.filter((policy) => (
policy?.dataProductId === "fleet.positions.current.v4" && policy?.productVersion === "4.0.0"
)) || [];
if (matches.length !== 1) throw new Error("foundry_consumer_policy_v4_missing_or_ambiguous");
const policy = matches[0];
if (movingObjectV4Matches.length !== 1) throw new Error("foundry_consumer_policy_v4_missing_or_ambiguous");
const movingObjectV4Policy = movingObjectV4Matches[0];
if (
policy.id !== "map-moving-object-current-v4"
|| policy.version !== "4.0.0"
|| policy.staleAfterMs !== null
|| policy.statusContract?.attribute !== "signal_state"
|| JSON.stringify(policy.statusContract?.allowedValues) !== JSON.stringify(["active", "inactive"])
|| policy.statusContract?.missing !== "reject"
|| policy.statusContract?.freshness !== "none"
|| JSON.stringify(policy.terminalStatuses) !== JSON.stringify(["inactive"])
|| policy.removeMode !== "canonical-tombstone-or-snapshot-rebase"
movingObjectV4Policy.id !== "map-moving-object-current-v4"
|| movingObjectV4Policy.version !== "4.0.0"
|| movingObjectV4Policy.staleAfterMs !== null
|| movingObjectV4Policy.statusContract?.attribute !== "signal_state"
|| JSON.stringify(movingObjectV4Policy.statusContract?.allowedValues) !== JSON.stringify(["active", "inactive"])
|| movingObjectV4Policy.statusContract?.missing !== "reject"
|| movingObjectV4Policy.statusContract?.freshness !== "none"
|| JSON.stringify(movingObjectV4Policy.terminalStatuses) !== JSON.stringify(["inactive"])
|| movingObjectV4Policy.removeMode !== "canonical-tombstone-or-snapshot-rebase"
) throw new Error("foundry_consumer_policy_v4_contract_invalid");
const serializedPolicy = JSON.stringify(policy);
if (/(provider|tenant|connection|endpoint|credential|token|secret|authorization)/i.test(serializedPolicy)) {
throw new Error("foundry_consumer_policy_v4_transport_boundary_violation");
const zoneV1Matches = registry.policies?.filter((policy) => (
policy?.dataProductId === "map.zones.current.v1" && policy?.productVersion === "1.0.0"
)) || [];
if (zoneV1Matches.length !== 1 || JSON.stringify(zoneV1Matches[0]) !== JSON.stringify({
id: "map-zone-current-v1",
version: "1.0.0",
dataProductId: "map.zones.current.v1",
productVersion: "1.0.0",
freshness: "none",
staleAfterMs: null,
terminalStatuses: [],
removeMode: "canonical-tombstone-or-snapshot-rebase",
})) throw new Error("foundry_consumer_policy_zone_v1_contract_changed");
const zoneV2Matches = registry.policies?.filter((policy) => (
policy?.dataProductId === "map.zones.current.v2" && policy?.productVersion === "2.0.0"
)) || [];
if (zoneV2Matches.length !== 1) throw new Error("foundry_consumer_policy_zone_v2_missing_or_ambiguous");
const zoneV2Policy = zoneV2Matches[0];
const expectedProjection = [
"display_name",
"geometry_kind",
"max_speed_kph",
"schedule_timezone",
"applies_to_couriers",
"applies_to_kicksharing",
];
if (
zoneV2Policy.id !== "map-zone-current-v2"
|| zoneV2Policy.version !== "2.0.0"
|| zoneV2Policy.freshness !== "none"
|| zoneV2Policy.staleAfterMs !== null
|| JSON.stringify(zoneV2Policy.terminalStatuses) !== JSON.stringify([])
|| zoneV2Policy.consumerContract?.ontologyRevision !== "ontology.map.zone.v1"
|| zoneV2Policy.consumerContract?.deliveryMode !== "snapshot+patch"
|| JSON.stringify(zoneV2Policy.consumerContract?.semanticTypes) !== JSON.stringify(["map.zone"])
|| JSON.stringify(zoneV2Policy.consumerContract?.fieldProjection) !== JSON.stringify(expectedProjection)
|| JSON.stringify(zoneV2Policy.consumerContract?.geometryTypes) !== JSON.stringify(["Polygon", "MultiPolygon"])
|| zoneV2Policy.consumerContract?.subjectIdentity !== "semantic-type+source-id"
|| zoneV2Policy.consumerContract?.snapshotMode !== "atomic-replace"
|| zoneV2Policy.consumerContract?.patchMode !== "atomic"
|| zoneV2Policy.removeMode !== "canonical-tombstone-or-snapshot-rebase"
) throw new Error("foundry_consumer_policy_zone_v2_contract_invalid");
for (const [id, policy] of [["v4", movingObjectV4Policy], ["zone-v2", zoneV2Policy]]) {
if (/(provider|tenant|connection|endpoint|credential|token|secret|authorization)/i.test(JSON.stringify(policy))) {
throw new Error(`foundry_consumer_policy_${id}_transport_boundary_violation`);
}
}
const consumer = await readFile(resolve(foundryRoot, files[2]), "utf8");
for (const marker of [
"data_product_consumer_fact_status_invalid",
"data_product_consumer_status_field_not_projected",
'statusContract.freshness === "none"',
'policy.freshness === "none"',
"assertConsumerContract(policy.consumerContract, product, target.binding)",
"data_product_snapshot_product_mismatch",
"data_product_patch_product_mismatch",
"data_product_consumer_fact_contract_invalid",
]) {
if (!consumer.includes(marker)) throw new Error(`foundry_consumer_policy_v4_runtime_guard_missing:${marker}`);
if (!consumer.includes(marker)) throw new Error(`foundry_consumer_policy_runtime_guard_missing:${marker}`);
}
}