Skip to content

fix(mappings): follow network-specs #12/#13, and name a knowledge source by its title - #36

Merged
manjudr merged 1 commit into
release-0.0.1from
fix/align-mappings-to-pack
Sep 15, 2026
Merged

manjudr merged 1 commit into
release-0.0.1from
fix/align-mappings-to-pack

Conversation

@ameersohel45

Copy link
Copy Markdown
Collaborator

Summary

Brings this repo's mappings back in line with the copies helmcharts serves. They drifted when helmcharts#25 landed there first; the three files are byte-identical to that branch again, and pocra already was.

Three changes, two of them the schema pack's:

  1. network-specs#12 — a resolved location is a Beckn Location, GeoJSON under geo.
  2. network-specs#13 — MandiPrice drops commodity; supportedCommodities is the one coded collection in both modes.
  3. sourceName is the document's title, not the ingestion pipeline's filename.

Both upstream PRs are merged and their packs are published, so nothing here is waiting on anything.

Changes

#12 — location becomes a Beckn Location

The weather mapping both emits a location and reads one, and all four sites move:

site from to
what it writes {type, coordinates} {geo: {type, coordinates}}
required: precondition location.type location.geo.type
request half $lat/$lon location.coordinates location.geo.coordinates
response half $asked location.coordinates location.geo.coordinates

The read sites are the ones worth noting — converting only the write half refuses every select with SCH_INVALID_FORMAT: this capability needs a Point location, which reads like a bad payload and is actually the precondition looking where the geometry no longer is. That was caught in oan-local on the helmcharts side, not in review.

response.location.lat is untouched: that is the upstream's response shape, not Beckn's.

#13 — commodity folds into supportedCommodities

One entry per resource, not the caller's whole list. From that PR's compatibility note: a Direct resource's single prices object applies to every commodity listed. This mapping emits one resource per price record, each with its own prices — so listing more would claim that row's prices for commodities it never priced.

The code stays the caller's and the name the record's, because the upstream takes a commodity code and answers with a name only.

market needed nothing: #13 relaxes it to an anyOf across marketCode/marketName/district/state/location, and this mapping already emits three of the five.

sourceName is the document's title

was   "doc-d7124029cb60-rerun-1788841718"
now   "Karnataka Gruha Jyoti Scheme Guidelines"

No fallback, and the blank is the point. A document with no name_en gets "". Falling back to filename hides the gap behind something that looks like an answer but names nothing a reader can place; omitting the key leaves a consumer unable to tell "this document has no name" from "the provider reported nothing". sourceId survives either way, so the passage stays attributable.

title_en is not a third candidate — it exists on the hit and comes back empty on this corpus.

The tests are the work here

They encoded the old shapes, so each had to be re-argued rather than mechanically flipped.

WeatherObservation — the inbound fixture and the precondition helper both wrap the geometry, so the refusal cases (polygon, line string, multipoint, absent) still exercise the shape the mapping actually reads rather than passing for the wrong reason.

MandiPrice — supportedCommodities moves from the must-NOT-appear list to the required one, and a new assertion pins exactly one entry carrying a code.

KnowledgeAdvisory — the captured providerResponse predates name_en. The live provider returns it today, so the four hits gain the titles their two documents really carry; that makes the fixture current rather than fictional. The assertion now refuses a doc- prefix outright, so a silent regression to filenames fails loudly.

New: TestShippedMappingLeavesAnUnnamedSourceBlank covers the case the change exists to produce — name_en absent, empty, and whitespace-only all yield "" while sourceId survives.

Testing

  • go build ./..., go vet, and the full go test ./pkg/... are green
  • -race pass over all four capability plugins
  • The new blank-source test carries a negative control: restoring the filename fallback fails all three cases with sourceName = "doc-d1", want ""
  • The three mappings verified byte-identical to helmcharts release-0.0.1
  • The same mapping content was run end to end in oan-local on the helmcharts side — weather and mandi selects both answering on_select against the merged packs
  • Not re-run end to end from this repo

Notes

Based on release-0.0.1, not development. pocra's mapping on release-0.0.1 is already identical to helmcharts', and development is behind on it — basing there would have meant either porting someone else's POCRA work as a side effect or silently regressing it.

development is still behind on all four mappings and will need the same sync, including the pocra changes from helmcharts#20 and #21 that never came back here. Worth doing as its own pass rather than folding in here.

Brings this repo's mappings back in line with the copies helmcharts serves,
which drifted when OpenAgriNet/helmcharts#25 landed there first. The three
files are now byte-identical to that branch again; pocra already was.

THREE CHANGES, two of them the schema pack's.

network-specs#12 -- a resolved location is a Beckn Location, with the GeoJSON
under `geo`. The weather mapping both emits one and READS one, and all four
sites move: what it writes, the `required:` precondition, the request half's
$lat/$lon, and the response half's $asked echo.

network-specs#13 -- MandiPrice drops the singular `commodity`;
supportedCommodities is the one coded collection in both modes. ONE entry per
resource, because a Direct Resource's single prices object applies to every
commodity listed and this mapping emits one resource per price record.

And sourceName is hits[].name_en rather than hits[].filename -- a document
title ("Karnataka Gruha Jyoti Scheme Guidelines") instead of the ingestion
pipeline's artefact name ("doc-d7124029cb60-rerun-1788841718"). No fallback: a
document with no name_en gets "", because the blank reports a gap in the corpus
where a filename would hide it behind something that looks like an answer.

THE TESTS ARE THE WORK HERE. They encoded the old shapes, so each had to be
re-argued rather than mechanically flipped:

  WeatherObservation  the inbound fixture and the precondition helper both
                      wrap the geometry, so the refusal cases -- polygon, line
                      string, multipoint, absent -- still exercise the shape
                      the mapping actually reads
  MandiPrice          supportedCommodities moves from the must-NOT-appear list
                      to the required one, and a new assertion pins exactly one
                      entry carrying a code
  KnowledgeAdvisory   the captured providerResponse predates name_en, so the
                      four hits gain the titles their two documents really
                      carry; the assertion now refuses a "doc-" prefix outright

TestShippedMappingLeavesAnUnnamedSourceBlank is new and covers the case the
change exists to produce: name_en absent, empty, and whitespace-only all yield
"" while sourceId survives. It carries a negative control -- restoring the
filename fallback fails all three with `sourceName = "doc-d1", want ""`.

Based on release-0.0.1 rather than development: pocra's mapping there is
already identical to helmcharts', and development is behind on it, so basing
there would have meant porting or regressing someone else's work.

go build, go vet, the full go test ./pkg/... and a -race pass over all four
capability plugins are green.
@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

🛡️ Trivy security scan (CRITICAL,HIGH,MEDIUM,LOW)

View full run

Go dependencies

No findings at CRITICAL,HIGH,MEDIUM,LOW.

Container image

Package Severity Installed Fixed in Advisory
zlib MEDIUM 1.3.2-r7 1.3.3-r0 CVE-2026-85091

@github-actions

Copy link
Copy Markdown

📊 Test Coverage: ➖ Not applicable — no non-test Go files changed vs origin/release-0.0.1, so there are no lines to measure and no percentage to report.

@manjudr
manjudr merged commit d567878 into release-0.0.1 Sep 15, 2026
4 of 6 checks passed
@ameersohel45
ameersohel45 deleted the fix/align-mappings-to-pack branch September 16, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants