Repository navigation
feat(roads): add CIFS v2 inbound parser and outbound emitter - #464
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
Adds first-class CIFS v2 (Closure and Incident Feed Specification) support in both directions — inbound parsing (
format: "cifs", XML and JSON) and outbound publishing (GET /cifs.xmlandGET /cifs.json) — backed by the pinned official Google/Waze XML Schema (cifsv2.xsd), model crosswalk, and end-to-end PostGIS verification.Conformance & canonical model
packages/conformance/src/standards/cifs-v2.tspinninghttps://www.gstatic.com/road-incidents/cifsv2.xsdby SHA-256 (a82ffb2cd92610a739bc55c9ab4b270e66e74cb546a9f5e59a34ce9af45e0f6b) for test-timexmllint-wasmvalidation.packages/model-roads/src/vocabularies/cifs.ts(all 7 types, 36 XSD subtypes, 2 doc-only inbound subtypes, directions, roadsides, lane statuses) andpackages/model-roads/src/crosswalk/cifs.ts(CIFS_SITUATIONSand XSD-valid outboundCIFS_INCIDENTS). Registered"cifs"in@openconditions/model(MappingTarget) and@openconditions/model-roads(format: "cifs",external_id_schemeextended withcifs:incidentandcifs:parent_event), and regenerated model schemas, docs, and feed schemas.Inbound CIFS parser (
@openconditions/roads)parseCifsSnapshotandparseCifsinpackages/roads/src/cifs.tsfor CIFS XML (<incidents>) and CIFS JSON ({ incidents: [...] }, flat or wrapped{ incident: {...} }, plus legacy nestedlocationobjects with flat/legacy conflict rejection).cifsinSITUATION_PARSERS,SNAPSHOT_REPORTERS,ACCOUNTED_PARTIAL_FORMATS, andsituations("cifs", { reparseUnchanged: true, transactionalRoles: true }):situationsComplete: falsewith bounded retrieval TTL (freshness.expiresAt), only authorizing snapshot omission withdrawal when a catalogue source explicitly declaressnapshot: { completeness: "complete" }.304 Not Modifiedresponses replay the last accepted payload to renew retrieval TTL on healthy feeds; failed or malformed polls neither poison the held payload nor advance validators.success: false,ok: false,error/errors, and numeric or string HTTP error statuses such as"503"), malformed records, duplicate XML elements, explicit JSONnulls on critical fields, and conflicting duplicate IDs fail closed.(type, subtype)pairs before classification; accountsCHIT_CHATasterminal.roadState: "closed"onROAD_CLOSED*while retaining cause classification; marks closures missingstarttimeasvalidity.status = "unknown", and keeps single-point, circular, zero-length, or >20 km closuresnormalization: "partial"so they never route.ONE_DIRECTION/ omitted →positive/geometry) and never widens single-pointONE_DIRECTIONto bilateral.<lanes>/<lane_impact>strictly (0-based → 1-based normalization, non-traffic lane exclusion, empty<lane/>detection, count/roadside conflict downgrade, never synthesizingall_lanes_closed),<source>provenance,<parent_event>external IDs, and recurring<schedule>windows (rejecting DST-crossing windows including overnight transitions and end-only bounds).Outbound CIFS emitter & ingest API (
@openconditions/publishers,services/ingest)cifsIncidentsOf,situationsToCifsXml, andsituationsToCifsJsoninpackages/publishers/src/situation-cifs.tswith shared projection and diagnostics:cifsv2.xsdvalues (never writes deprecatedCONSTRUCTION,CHIT_CHAT, or doc-only subtypes).ROAD_CLOSEDonly for complete, active or confirmed-scheduled, mandatory, road-wide (non-lane-scoped) closures with explicitvalidity.startand a non-circularLineString(0 m < length ≤ 20,000 m on serialized 6-decimal coordinates).direction.value === "both").isAffirmativeLaneClosureandextractCompleteLanes), intersects bounded weekly occurrences in local timezone for cross-bucket lane conflict detection, enforces XML-safe code-point minimum lengths (@id≥ 3,<street>≥ 2,<description>≥ 1), and encodes incident IDs so root and split namespaces are disjoint, poll-stable, and immune to XML 1.0 §3.3.3 attribute whitespace normalization.GET /cifs.xmlandGET /cifs.jsoninservices/ingestbacked by a shared complete repeatable-read public snapshot helper (readCompletePublicSnapshot, 20,000-situation and 32 MiB byte caps, 413 JSON withCache-Control: no-store,X-Data-License), updatedservices/ingest/openapi.json, addedprojection.cifs/exports.cifstofeed-inspect, and documented the contract indocs/cifs.md,docs/speed-coverage.md,README.md, andservices/ingest/README.md.Verification and limits
All checks ran locally in this worktree against base
6b0edf98:pnpm build— passed (36/36 packages).pnpm lint(biome check,prettier --check,check-import-boundaries) — passed.pnpm typecheck— passed (69/69 packages).pnpm check-credentials,pnpm check:model,pnpm check:feed-schemas,pnpm feeds:lint— all passed.pnpm test:unit— passed (7,956+ unit tests across 572 test files, plus re-verification of all 8 CIFS-related test suites: 66/66 tests passing, includingxmllint-wasmvalidation against pinnedcifsv2.xsd, XML/JSON roundtrip, random fuzzing, OpenAPI drift, andfeed-inspect).pnpm exec vitest run --project integration services/ingest/src/__tests__/cifs-feed.integration.test.ts(Docker PostGIS 16 via Testcontainers) — passed (10/10 tests covering/cifs.xml,/cifs.json, XSD validation, query rejection, public scoping, 304 TTL renewal, transactional role recovery after malformed polls, string-status"503"failure envelope refusal, and qualified complete-feed withdrawal).Limits:
Release and upgrade impact
"cifs"to road feed formats,cifs:incident/cifs:parent_eventtoexternal_id_scheme, and public read endpointsGET /cifs.xmlandGET /cifs.jsontoservices/ingest. No database migrations or configuration changes are required for existing deployments.@openconditions/model-roads,@openconditions/roads, and@openconditions/publishersgain new additive CIFS exports;feed-inspectaddsprojection.cifsandexports.cifswhile retainingschemaVersion: 2.