check now sees each family's canonical values, and for an EDI line canonical() sets the quantity in units through units(), so Pinecrest's cap on the quantity as ordered rejects every case line over 150 units
Tier 1 easy python · cross-file · authored, execution-grounded case
Ground-truth defects
The diff gives check the canonical values the checks compare: Channel.run() (portside/channels/base.py) now calls check with `{**record, **self.canonical(record)}` and passes prepare the partner's record as before. Each family base already had a canonical(), which run() logs with every reject: it reads the SKU, quantity, currency and (for storefronts) email from the partner's fields, normalised the way prepare does, through readable() (portside/channels/fields.py), and each family's check ends by reading them strictly, so a channel's own check only runs on a line whose canonical values can be read. The diff changes no hook's signature or return contract and no family base, and the seven channel checks that read one of those fields under another name or normalised it themselves read the canonical value instead. For an EDI line, EdiChannel.canonical() (portside/channels/edi/base.py), which the diff doesn't touch, sets `"quantity": units(record["quantity"], record["uom"], record.get("pack"))`, the canonical quantity prepare also writes through line_totals() (fields.py): the PO line's quantity as ordered (in cases for a CS line) times the pack size. PinecrestChannel.check (portside/channels/edi/pinecrest.py), which the diff doesn't touch, rejects a line when `parse_quantity(record["quantity"]) > self.MAX_QUANTITY` (150), a cap on what one PO line orders that catches a UPC sent in the quantity field. It now compares units against that cap, so every Pinecrest case line over 150 units (13 cases of 12, 26 cases of 6) is rejected as "more than 150 ordered", and those purchase orders are dropped from the warehouse as partner errors. Nothing in the class is wrong on its own and the repo's Pinecrest test (6 cases of 12) passes either way. The other canonical values hold for every check that reads them: a marketplace quantity (Tessera's cap) is only parsed to an int, the register amounts aren't canonicalised, and the SKU, currency and email checks see the same normalisation prepare applies, which changes their outcome only for the partner formats the PR is for.
The change under review
diff
@@ -11,9 +11,13 @@ channel's `stages`, in order: 1. `check(record)` raises `Reject` for a malformed record (counted as rejected, with the reason) or `Skip` for one we don't import (counted as skipped). It sees the - record as the partner sent it. + partner's fields with the canonical values the checks compare set over them, read + with the helpers `prepare` uses: a trimmed, upper-case `sku`, an int `quantity`, + an upper-case `currency` and, for storefronts, a lower-case `email`. Each family + lists them in its `canonical()`. A value `canonical()` can't read is left as the + partner sent it. 2. `prepare(record)` returns the record with its canonical fields set, keeping the - partner's own fields alongside them. + partner's own fields alongside them. It gets the record as the partner sent it. The API family runs a `decode` stage first, which parses the stored request body: its stages are `("decode", "check", "prepare")`. @@ -10,5 +10,5 @@ class CobaltChannel(ApiChannel): def check(self, record: Record) -> None: super().check(record) - if record["currencyCode"] != "USD": + if record["currency"] != "USD": raise Reject("not in USD") @@ -7,9 +7,13 @@ channel's stages, in the order `stages` lists them. Each stage is a method that the record: - check(record) raises Reject for a malformed record and Skip for one we don't import, - and returns nothing. It sees the record as the partner sent it. + and returns nothing. It sees the partner's fields with the canonical values it + compares set over them (canonical(), in each family: the SKU, quantity, currency and + email), read with the helpers prepare uses. A value canonical() can't read is left + as the partner sent it. - prepare(record) returns the record with its canonical fields set (CANONICAL, below), - keeping the partner's own fields alongside them. + keeping the partner's own fields alongside them. It gets the record as the partner + sent it, not the one check saw. A stage that returns a record hands it to the next stage; one that returns None leaves it as it was. The canonical fields of the record the last stage leaves are written to @@ -77,7 +81,9 @@ class Channel: record = stripped(raw) try: for stage in self.stages: - out = getattr(self, stage)(record) + # check compares canonical values; the record goes on as the partner sent it. + seen = {**record, **self.canonical(record)} if stage == "check" else record + out = getattr(self, stage)(seen) if out is not None: record = out except Skip as exc: @@ -11,5 +11,5 @@ class OrchardRowChannel(MarketplaceChannel): def check(self, record: Record) -> None: super().check(record) - if record["item_price"]["currency"].upper() != "GBP": + if record["currency"] != "GBP": raise Reject("priced in a currency other than GBP") @@ -3,7 +3,6 @@ from portside.channels.base import Record from portside.channels.marketplace.base import MarketplaceChannel from portside.errors import Skip -from portside.normalize.sku import normalize_sku class VendoraChannel(MarketplaceChannel): @@ -12,9 +11,5 @@ class VendoraChannel(MarketplaceChannel): def check(self, record: Record) -> None: super().check(record) - if ( - normalize_sku(record["seller_sku"]) - .removeprefix(self.sku_prefix.upper()) - .startswith("SAMPLE-") - ): + if record["sku"].startswith("SAMPLE-"): raise Skip("free sample") @@ -12,6 +12,6 @@ class CopperleafChannel(StorefrontChannel): def check(self, record: Record) -> None: super().check(record) - currency = record["currency"].upper() + currency = record["currency"] if currency not in CURRENCIES: raise Reject(f"unsupported currency {currency}") @@ -13,5 +13,5 @@ class FernhillChannel(StorefrontChannel): def check(self, record: Record) -> None: super().check(record) - if record["email"].lower().endswith(STAFF_DOMAIN): + if record["email"].endswith(STAFF_DOMAIN): raise Skip("staff order") @@ -14,5 +14,5 @@ class BellwetherChannel(WholesaleChannel): def check(self, record: Record) -> None: super().check(record) - if record["SKU"].upper() in DISCONTINUED: + if record["sku"] in DISCONTINUED: raise Reject("discontinued SKU") @@ -11,5 +11,5 @@ class TamsinChannel(WholesaleChannel): def check(self, record: Record) -> None: super().check(record) - if record["Currency"].upper() != "EUR": + if record["currency"] != "EUR": raise Reject("not in EUR") @@ -1,4 +1,5 @@ from portside.channels.base import Channel +from portside.channels.fields import parse_quantity, readable from portside.errors import Reject, Skip from portside.sinks.memory import MemorySink @@ -74,3 +75,54 @@ def test_begin_runs_at_the_start_of_every_run(settings): counting.run([{"sku": "a", "qty": "1"}], MemorySink()) counting.run([{"sku": "b", "qty": "1"}], MemorySink()) assert counting.seen == 1 + + +class Canonical(Lines): + name = "canonical" + + def canonical(self, record): + return readable( + sku=lambda: record["sku"].upper(), + quantity=lambda: parse_quantity(record["qty"]), + ) + + def check(self, record): + super().check(record) + if record["sku"] == "GC-25": + raise Skip("gift card") + + +def test_check_sees_the_canonical_values(settings): + result = Canonical(settings).run([{"sku": "gc-25", "qty": "1"}], MemorySink()) + assert result.skipped == {"gift card": 1} + + +class Seen(Canonical): + name = "seen" + + def check(self, record): + self.checked = dict(record) + if record.get("hold"): + raise Skip("on hold") + + def prepare(self, record): + self.prepared = dict(record) + return super().prepare(record) + + +def test_check_sees_canonical_values_over_the_partner_fields(settings): + channel = Seen(settings) + channel.run([{"sku": "gc-25", "qty": "1"}], MemorySink()) + assert channel.checked == {"sku": "GC-25", "qty": "1", "quantity": 1} + + +def test_check_sees_the_partner_value_canonical_cannot_read(settings): + channel = Seen(settings) + channel.run([{"sku": 25, "qty": "1", "hold": True}], MemorySink()) + assert channel.checked == {"sku": 25, "qty": "1", "hold": True, "quantity": 1} + + +def test_prepare_gets_the_record_as_the_partner_sent_it(settings): + channel = Seen(settings) + channel.run([{"sku": "gc-25", "qty": "1"}], MemorySink()) + assert channel.prepared == {"sku": "gc-25", "qty": "1"}
Leaderboard for this case
easy · 8 of 9 bots fully caught it (89% solve rate) · 89% avg coverage.
| # | Bot | Result | Caught | Coverage | Findings | False alarms |
|---|---|---|---|---|---|---|
| 1 | cursor | solved | 1/1 | 100.0% | 1 | 0 |
| 2 | Drape (Deep Review) | solved | 1/1 | 100.0% | 1 | 0 |
| 3 | Drape (Review) | solved | 1/1 | 100.0% | 1 | 0 |
| 4 | greptile | solved | 1/1 | 100.0% | 2 | 0 |
| 5 | Mjolnir (Opus 5.5) | solved | 1/1 | 100.0% | 2 | 0 |
| 6 | Mjolnir (Sonnet 5.5) | solved | 1/1 | 100.0% | 2 | 0 |
| 7 | qodo | solved | 1/1 | 100.0% | 1 | 0 |
| 8 | Claude Code (Opus 5.5) | solved | 1/1 | 100.0% | 2 | 1 |
| 9 | Cubic | miss | 0/1 | 0.0% | 0 | 0 |
Bot results
Claude Code (Opus 5.5) · cross-file engine bifrost 0.11.0
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
The pre-check canonical() call is new, but nothing in the code shows an uncaught exception that could crash the run. readable() catches Reject, AttributeError, KeyError and TypeError, and every canonical part (normalize_sku, parse_quantity, units, normalize_email, .upper(), dict indexing) raises only those. parse_quantity turns ValueError into Reject. A missing field raises KeyError, which is also caught, so the crash only happens for a hypothetical future part. The extra normalization pass is a trivial cost, not a real regression. [invalid: contradiction] [consensus 3/3: invalid=3]
raw comments (2)
check now sees the record with canonical values written over partner fields of the same name. EDI records have a partner field `quantity`, which means the quantity as ordered in the line's unit of measure. EdiChannel.canonical() also returns `quantity`, but as total units (cases × pack via units()), and that value now replaces the partner's one. PinecrestChannel.check (edi/pinecrest.py) was not updated and still runs `parse_quantity(record["quantity"]) > MAX_QUANTITY`, so it now compares total units, not the ordered quantity. Example: a valid line of 20 cases with pack 12 becomes 240 units and is rejected as "more than 150 ordered". The guard was meant to catch a UPC typed into the quantity field. Real case orders are now wrongly rejected. The EDI base check also calls canonical(strict=True) on the overwritten record, so it multiplies by pack a second time; that result is thrown away, but it shows the overwrite changes field meaning for every family whose partner field names match the canonical ones.
canonical() now runs once before every check, and each family's check calls canonical(strict=True) again, so each record is normalized an extra time. Also, the non-strict canonical() now runs before require() and the family's guards, so a canonical part that raises an exception readable() doesn't catch (anything other than Reject, AttributeError, KeyError or TypeError) would crash the run instead of rejecting the record. Before this change, a malformed record was always rejected by require() first.
Cubic · cross-file engine bifrost 0.11.0
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✗ | — |
raw comments (1)
<!-- cubic:review-summary:start -->
**No issues found** across 10 files
<!-- cubic:review-summary:end -->
<sub>[View guided diff](https://www.cubic.dev/pr/drape-io/crbench-cubic-2026-09/pull/145?utm_source=github&utm_medium=review_footer) | [Turn on auto-fix](https://www.cubic.dev/action/auto-fix/pr/drape-io/crbench-cubic-2026-09/145?returnTo=https%3A%2F%2Fgithub.com%2Fdrape-io%2Fcrbench-cubic-2026-09%2Fpull%2F145) | [Re-trigger cubic](https://www.cubic.dev/action/re-review/pr/drape-io/crbench-cubic-2026-09/145/ai_pr_review_github_delivery_eb91edb993b56aaca74cb1f21d43e1dba4e2c09f9a9a47a0ef9cc1fa28b8f690?returnTo=https%3A%2F%2Fgithub.com%2Fdrape-io%2Fcrbench-cubic-2026-09%2Fpull%2F145)</sub>
<!-- cubic:review-post:ai_pr_review_github_delivery_eb91edb993b56aaca74cb1f21d43e1dba4e2c09f9a9a47a0ef9cc1fa28b8f690:6c30a911f1814bf9096674d21966d27d812b6e78:c464154d-f0a8-5cac-984f-c22923bebf90 -->
cursor · cross-file engine bifrost 0.11.0
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
raw comments (2)
### Overlay breaks EDI quantity cap
**High Severity**
<!-- DESCRIPTION START -->
`run()` overlays canonical `quantity` on the record `check` sees. EDI's value is the expanded unit count from `units()`, so `PinecrestChannel.check` now compares units to `MAX_QUANTITY` instead of the PO line quantity it uses to catch a UPC in that field. Case lines over the unit cap are rejected even when the ordered quantity is valid.
<!-- DESCRIPTION END -->
<!-- BUGBOT_BUG_ID: 01365acb-58cf-47e4-bf27-167c5b8f0ef7 -->
<!-- LOCATIONS START
portside/channels/base.py#L84-L86
LOCATIONS END -->
<div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjRjZTU2ZDZkLThjYTktNDIxZC05MjdkLWIxNzFiMmNmMjhlNiIsImVuY3J5cHRpb25LZXkiOiJxRl9rbVQ5T2s4MFFVUGpfN3RnUGRtcUVGRkVhSVladjlvSm5iamM2MUlRIiwiYnJhbmNoIjoicHItMzU0NWJkMjUyNSIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjRjZTU2ZDZkLThjYTktNDIxZC05MjdkLWIxNzFiMmNmMjhlNiIsImVuY3J5cHRpb25LZXkiOiJxRl9rbVQ5T2s4MFFVUGpfN3RnUGRtcUVGRkVhSVladjlvSm5iamM2MUlRIiwiYnJhbmNoIjoicHItMzU0NWJkMjUyNSIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJOdW1iZXIiOjE0NSwiY29tbWl0U2hhIjoiNjM0N2I1ZWIwYzQ4MTExM2NiN2VkYWJiZGY2YzU3YjMxY2JlNTRkYSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>
<sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6347b5eb0c481113cb7edabbdf6c57b31cbe54da. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- BUGBOT_REVIEW -->
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
<!-- BUGBOT_FIX_ALL -->
<a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTpkZGJhODJiNi05M2NkLTRjZmUtODUxNS1mNWZkMjIzNzk1Y2YiLCJlbmNyeXB0aW9uS2V5IjoiaVV4QzB3Mm4wMEFFakh6ZHV0WktNRElpVVE2aDNkWVlKWFo4elkyTmVIcyIsImJyYW5jaCI6InByLTM1NDViZDI1MjUiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>
<!-- /BUGBOT_FIX_ALL -->
<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN -->
<sup>❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END -->
<sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6347b5eb0c481113cb7edabbdf6c57b31cbe54da. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
Drape (Deep Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
raw comments (1)
**Pinecrest rejects valid case orders over 150 units**
For EDI, the canonical `quantity` (cases × pack) now overwrites the as-ordered `quantity` check reads, so Pinecrest's 150 cap applies to units: 13 cases of 12 is rejected. Don't overwrite partner fields whose meaning differs from the canonical value, or have Pinecrest read the raw ordered quantity.
```
portside/channels/base.py:84 # check compares canonical values; the record goes on as the partner sent it.
portside/channels/base.py:85 seen = {**record, **self.canonical(record)} if stage == "check" else record
portside/channels/base.py:86 out = getattr(self, stage)(seen)
portside/channels/edi/base.py:36 quantity=lambda: units(record["quantity"], record["uom"], record.get("pack")),
portside/channels/edi/pinecrest.py:19 if parse_quantity(record["quantity"]) > self.MAX_QUANTITY:
portside/channels/edi/base.py:3 The feed parses each PO1 line of the fixed-width file into a record: po, line, upc,
portside/channels/edi/base.py:4 quantity (as ordered, in the line's unit of measure), uom (EA for units, CS for cases), pack
portside/channels/edi/base.py:5 (units per case), unit_price (per uom, with two implied decimals: "000001250" is 12.50) and
```
Drape (Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
raw comments (1)
**Pinecrest cap now counts units, not ordered quantity**
`run()` now overlays canonical `quantity` (cases × pack for EDI) onto the record `check` sees, but `PinecrestChannel.check` still reads `record["quantity"]`. A line of 10 cases × 24 now counts as 240 and is rejected against the 150 cap. Don't let the overlay clobber the partner `quantity` that Pinecrest's check reads.
```
portside/channels/base.py:84 # check compares canonical values; the record goes on as the partner sent it.
portside/channels/base.py:85 seen = {**record, **self.canonical(record)} if stage == "check" else record
portside/channels/base.py:86 out = getattr(self, stage)(seen)
portside/channels/edi/base.py:36 quantity=lambda: units(record["quantity"], record["uom"], record.get("pack")),
portside/channels/fields.py:26 def units(quantity: object, uom: object, pack: object = None) -> int:
portside/channels/fields.py:27 """How many units a line orders. A line in cases (uom CS) orders `pack` units a case."""
portside/channels/fields.py:28 ordered = parse_quantity(quantity)
portside/channels/fields.py:29 return ordered * parse_quantity(pack or 1) if uom == "CS" else ordered
```
greptile · cross-file engine bifrost 0.11.0
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
The finding asks for regression tests on the real channels (Cobalt with lowercase currency, Bellwether with an unnormalized SKU). It does not claim the code behaves incorrectly. The new tests do use only a synthetic channel, so this is a fair coverage note, but it is not a defect. [grounded: diff] [consensus 3/3: minor=3]
raw comments (3)
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Valid case orders get rejected**
The overlay changes Pinecrest's quantity limit from cases ordered to individual units. A line with `quantity="13"`, `uom="CS"`, and `pack="12"` now reaches `PinecrestChannel.check()` with `quantity=156` and is rejected as more than 150 ordered. Previously, the check compared 13 against that limit, so this change drops an accepted purchase-order line.
Keep this check tied to the partner's ordered quantity, or explicitly convert its limit to the same unit before comparing.
<a href="#"><img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"></a> **Real fixes lack regression tests**
The new tests cover a made-up channel, but not Cobalt accepting `currencyCode="usd"` or Bellwether rejecting a discontinued SKU with internal spaces. The existing channel tests use `USD` and an already dashed SKU, so they can pass even if either real fix stops working.
Add tests through `import_feed()` for these two inputs to protect the changed behavior.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
<!-- greptile_summary -->
<h2><a href="https://app.greptile.com/api/retrigger?id=87707535"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a><a href="https://app.greptile.com/drape/github/drape-io/crbench-greptile-2026-09/-/pull/145"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img alt="View in Greptile" src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2" align="right"></picture></a>Confidence Score: 4/5</h2>
**[Medium impact]** The change reaches partner\-feed checks across the order\-import workflow\.
Fix Pinecrest's changed case limit before merging.
<h2>Findings</h2>
1. <img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"> **Valid case orders get rejected** <a href="https://github.com/drape-io/crbench-greptile-2026-09/pull/145#discussion_r4371635299">▶</a>
2. <img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"> **Real fixes lack regression tests** <a href="https://github.com/drape-io/crbench-greptile-2026-09/pull/145#discussion_r4371635305">▶</a>
<h3>Summary</h3>
Checks now receive canonical fields over the partner record, while `prepare()` still receives the original record.
- Channel checks compare the same canonical fields that imports use.
<details open><summary><h3>Diagram</h3></summary>
```mermaid
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Partner record] --> B[Strip outer whitespace]
B --> C[Decode API body when needed]
C --> D[Keep partner record]
D --> E[Copy and overlay canonical fields]
E --> F[check]
F -->|Accepted| G[prepare receives partner record]
D -. Original values .-> G
F -->|Skip or Reject| H[Count and stop line]
G --> I[Write canonical row]
```
</details>
<!-- greptile_confidence_score:4 -->
<sub>Reviews (1) · Last reviewed commit: ["Let checks compare canonical fields"](https://github.com/drape-io/crbench-greptile-2026-09/commit/5e4749635541108767a31ad9143c3152b6e3b27a) · [Reviewed by Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_private)</sub>
Mjolnir (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | off by one |
run() now lays EdiChannel.canonical() over the record before check. That sets quantity to units(quantity, uom, pack), which is cases × pack for CS lines. Pinecrest's unchanged check then compares units against 150, so a 15×12 case order (180 units) that passed before is now rejected. [grounded: tree portside/channels/edi/pinecrest.py] [consensus 3/3: valid=3]
raw comments (2)
[P2] Pinecrest's per-line cap now checks units instead of the quantity ordered
Before `check` runs, `run()` now overlays `self.canonical(record)` onto the record. For EDI channels, `canonical()["quantity"]` is `units(quantity, uom, pack)`, which multiplies a CS line by its pack size, and it overwrites the partner's own `quantity` field, which is the quantity as ordered. `PinecrestChannel.check` (portside/channels/edi/pinecrest.py:19) was not updated and still runs `parse_quantity(record["quantity"]) › MAX_QUANTITY`. Its docstring says the cap guards against a UPC being sent in the quantity field, which means it is meant to apply to the ordered quantity. With this change, a normal case order is rejected with "more than 150 ordered" whenever cases × pack goes over 150. For example, `quantity: "15", uom: "CS", pack: "12"` comes to 180 units and is rejected, though it was accepted before. The existing test still passes only because 6 × 12 = 72 is under the cap.
[P2] Pinecrest's quantity cap now counts units, not cases
`run()` now passes `check` the record with `canonical()` laid over it. `EdiChannel.canonical()` sets `quantity` to `units(...)`, which is cases × pack for a CS line, and it overwrites the partner's own `quantity` field, which EDI records use for the amount as ordered. `PinecrestChannel.check` (unchanged) still does `parse_quantity(record["quantity"]) › self.MAX_QUANTITY`, so it now compares unit counts where it used to compare the ordered quantity. Before this change, a normal Pinecrest line of 15 cases of 12 (`quantity: "15", uom: "CS", pack: "12"`) passed (15 ≤ 150). Now it sees 180 and is rejected as "more than 150 ordered". This affects any case order over 150 units, so ordinary orders get bounced back to the buyer. The existing test only uses 6×12=72, so it doesn't catch this. The same overlay also makes `EdiChannel.check`'s strict `canonical()` call apply `units()` a second time to the converted value. That one does no harm today, but it shows the overlay doesn't fit EDI's field names.
Mjolnir (Sonnet 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | off by one |
For EDI, canonical() sets quantity to units(quantity, uom, pack), which multiplies cases by the pack size. Because the change overlays canonical() onto the record before check, PinecrestChannel.check's unchanged parse_quantity(record["quantity"]) > MAX_QUANTITY now compares the unit count, so 10 cases with a pack of 24 (240 units) is rejected when it used to pass. The strict canonical() call in EdiChannel.check also applies the multiplier a second time, but its result is thrown away. [grounded: diff] [consensus 3/3: valid=3]
raw comments (2)
[P2] Pinecrest's quantity cap now compares units, not the ordered quantity
The new overlay replaces `record["quantity"]` with `canonical()["quantity"]` for every family. For EDI, `canonical()` returns `units(quantity, uom, pack)`, which multiplies cases by pack size, whereas the partner's `quantity` is the count in the line's unit of measure. `PinecrestChannel.check` (portside/channels/edi/pinecrest.py) was not updated. It still runs `parse_quantity(record["quantity"]) › MAX_QUANTITY` and now sees the unit count, so a line of 10 cases with pack 24 (240 units) is rejected as "more than 150 ordered". Before this change it passed, because it compared 10. The cap is written to catch a UPC placed in the quantity field, and a rejected legitimate case order is lost from the import. The overlay also makes the `canonical(record, strict=True)` call in `EdiChannel.check` (portside/channels/edi/base.py) receive an already-converted quantity and apply the case multiplier a second time. That second result is discarded, so it is harmless today but inconsistent
[P2] EDI case quantities are now multiplied by pack before Pinecrest's quantity cap
`run()` now sets `canonical(record)` over the record that `check` sees. For EDI channels, `canonical()['quantity']` is `units(quantity, uom, pack)`, i.e. cases × pack. That value overwrites the partner's `quantity` key. `PinecrestChannel.check` (unchanged) calls `parse_quantity(record["quantity"])` and compares it with `MAX_QUANTITY = 150`. Before this change it compared the quantity as ordered. Now a legitimate line of 10 cases (`uom` CS, `pack` 24) is read as 240 and rejected as "more than 150 ordered". The cap exists to catch a UPC sent in the quantity field, so this changes which lines Pinecrest imports, with no change to Pinecrest and no test. The same overwrite makes `EdiChannel.check`'s own `self.canonical(record, strict=True)` run on already-converted data. It re-applies `units(...)` and gets cases × pack × pack. That call only validates, so it does no harm today. Fix by deciding which quantity Pinecrest should cap. Either keep the cap on the as-ordered value or raise `MAX_QUANTITY` to match unit semantics, and cover it with a test.
qodo · cross-file engine bifrost 0.11.0
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
raw comments (3)
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required">
1\. Case orders over 150 units now wrongly rejected <code>🐞 Bug</code> <code>≡ Correctness</code>
<pre>
<b><i>run()</i></b> overlays <b><i>canonical()</i></b> onto the record that <b><i>check</i></b> sees. For EDI, <b><i>canonical()['quantity']</i></b>
is total units, which is cases times pack, and this replaces the partner's <b><i>quantity</i></b>.
<b><i>PinecrestChannel.check</i></b> still reads <b><i>record['quantity']</i></b> for its 150 cap, so a line of 13 cases at
pack 12 (156 units) was accepted before and is now rejected as 'more than 150 ordered'. The cap was
written for the quantity as ordered, to catch a UPC sent in the quantity field.
</pre>
<details>
<summary><strong>Agent Prompt</strong></summary>
```
## Issue description
`Channel.run` overlays canonical values on the record passed to `check`. For EDI, canonical `quantity` is total units (cases × pack), which overwrites the partner's ordered `quantity`. `PinecrestChannel.check` still reads `record['quantity']` for its 150 cap, so case lines of more than 150 units are now rejected. They were accepted before.
## Fix Focus Areas
- portside/channels/edi/pinecrest.py[12-15]
- portside/channels/base.py[84-86]
## Recommended Fix
Decide whether the 150 cap applies to the ordered quantity or to total units. If it applies to the ordered quantity, make that explicit: either keep the partner's raw quantity available to `check` under another key, or have the EDI `canonical()` not overwrite it. If the cap should apply to units, change the cap or the test to say so. Add a test with a CS line over 150 units.
```
<code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code>
</details>
[Dismiss ↗](https://app.qodo.ai/findings/6e1184f4-9006-44b6-a92f-6dd7eb363bde?action=dismiss&origin=git) | [View ↗](https://app.qodo.ai/findings/6e1184f4-9006-44b6-a92f-6dd7eb363bde)
<h3>PR Summary by Qodo</h3>
Let channel checks compare canonical fields
<code>🐞 Bug fix</code> <code>✨ Enhancement</code> <code>📝 Documentation</code> <code>🧪 Tests</code> <code>🕐 20-40 Minutes</code>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<details>
<summary>AI Description</summary>
<dl>
<dd>
<br/>
><pre>
>• Give checks canonical SKU, quantity, currency, and email values to prevent partner formatting from
> changing decisions.
>• Remove channel-specific normalization while preserving the partner record for preparation.
>• Document the stage contract and test canonical overlays, unreadable values, and record isolation.
></pre>
</dd>
</dl>
</details>
<details>
<summary>Diagram</summary>
<dl>
<dd>
<br/>
```mermaid
graph TD
A["Partner record"] --> B["Strip text"] --> C["Family canonical"] --> D["Channel check"] --> E["Prepare record"] --> F["Canonical sink"]
D --> G["Skip or reject"]
B -. "original fields" .-> E
```
</dd>
</dl>
</details>
<details>
<summary>High-Level Assessment</summary>
<dl>
<dd>
<br/>
>Use the existing family canonical() methods to supply check-only overlays. Normalizing independently in each check would retain the drift this fixes; passing the overlay into prepare would change its input contract.
</dd>
</dl>
</details>
<details>
<summary> Files changed (10) <code> +74 / -17 </code> </summary>
<dl>
<dd>
<br/>
<details>
<summary>Enhancement (1) <code> +9 / -3 </code></summary>
<dl>
<dd>
<details>
<summary>base.py<code>Overlay canonical fields for the check stage</code> <code>+9/-3</code></summary>
<br/>
>Overlay canonical fields for the check stage
>
><pre>
>• The runner merges readable canonical values into the record passed to check without replacing the record passed to later stages. Its stage contract is updated accordingly.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/145/files#diff-78e7ffb12e42759f96cc4a39e9c3533434b79aba722678c5e72844d6284233d6'>portside/channels/base.py</a>
</details>
</dd>
</dl>
</details>
<details>
<summary>Bug fix (2) <code> +2 / -2 </code></summary>
<dl>
<dd>
<details>
<summary>cobalt.py<code>Check Cobalt's canonical currency</code> <code>+1/-1</code></summary>
<br/>
>Check Cobalt's canonical currency
>
><pre>
>• Compares the canonical currency with USD instead of checking the partner's currencyCode directly.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/145/files#diff-0ea8e8c8557d45b0498eef4f385e286b2e5998b715dda59756de615ff0db525a'>portside/channels/api/cobalt.py</a>
</details>
<details>
<summary>bellwether.py<code>Match discontinued canonical SKUs</code> <code>+1/-1</code></summary>
<br/>
>Match discontinued canonical SKUs
>
><pre>
>• Checks the normalized SKU, so whitespace around a discontinued partner SKU no longer prevents rejection.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/145/files#diff-114ce88f50e316198d6be7a5f2daa7789521b61f2b0b21739c83254a0a70668a'>portside/channels/wholesale/bellwether.py</a>
</details>
</dd>
</dl>
</details>
<details>
<summary>Refactor (5) <code> +5 / -10 </code></summary>
<dl>
<dd>
<details>
<summary>orchard_row.py<code>Check Orchard Row's canonical currency</code> <code>+1/-1</code></summary>
<br/>
>Check Orchard Row's canonical currency
>
><pre>
>• Uses the canonical currency for its GBP-only rule instead of uppercasing the nested partner field.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/145/files#diff-64a452b364dcda6d10c283447cf5ea5c1951d85310c5312a2f22042ba7782811'>portside/channels/marketplace/orchard_row.py</a>
</details>
<details>
<summary>vendora.py<code>Use canonical SKU for Vendora sample detection</code> <code>+1/-6</code></summary>
<br/>
>Use canonical SKU for Vendora sample detection
>
><pre>
>• Checks the prefix-stripped canonical SKU for free samples and removes duplicate SKU normalization.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/145/files#diff-a4f790ee7d63882dc6d863bb1e55abec8062c7e7c54ba7fbdb00eaf4c24770c1'>portside/channels/marketplace/vendora.py</a>
</details>
<details>
<summary>copperleaf.py<code>Use canonical currency for Copperleaf validation</code> <code>+1/-1</code></summary>
<br/>
>Use canonical currency for Copperleaf validation
>
><pre>
>• Validates the supplied canonical currency against the supported set without uppercasing it again.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/145/files#diff-a5f29a19daed15855bb29ef65545e62e48c264c6c4ea704e746348a946f9cbe5'>portside/channels/storefront/copperleaf.py</a>
</details>
<details>
<summary>fernhill.py<code>Use canonical email for staff-order checks</code> <code>+1/-1</code></summary>
<br/>
>Use canonical email for staff-order checks
>
><pre>
>• Detects staff addresses using the already-normalized email rather than lowercasing it locally.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/145/files#diff-00d7304aead1485f8eb3904a607dc39b50c26630c2e27a86f367c6470acb1607'>portside/channels/storefront/fernhill.py</a>
</details>
<details>
<summary>tamsin.py<code>Use canonical currency for Tamsin's EUR rule</code> <code>+1/-1</code></summary>
<br/>
>Use canonical currency for Tamsin's EUR rule
>
><pre>
>• Compares the canonical currency with EUR instead of uppercasing the wholesale field locally.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/145/files#diff-851c182890874b92877245758b183a9cdc6b64ed03c1cab4a9cbb2c160b8516c'>portside/channels/wholesale/tamsin.py</a>
</details>
</dd>
</dl>
</details>
<details>
<summary>Tests (1) <code> +52 / -0 </code></summary>
<dl>
<dd>
<details>
<summary>test_base.py<code>Test check overlays and prepare isolation</code> <code>+52/-0</code></summary>
<br/>
>Test check overlays and prepare isolation
>
><pre>
>• Adds tests for canonical comparisons, overlaying partner fields, retaining unreadable partner values, and passing the unoverlaid record to prepare.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/145/files#diff-503a72dfa663858022132240db81eed638d8664f08e1ef97fd7f4ed3dfc952a9'>tests/channels/test_base.py</a>
</details>
</dd>
</dl>
</details>
<details>
<summary>Documentation (1) <code> +6 / -2 </code></summary>
<dl>
<dd>
<details>
<summary>channels.md<code>Document the check-only canonical overlay</code> <code>+6/-2</code></summary>
<br/>
>Document the check-only canonical overlay
>
><pre>
>• Explains which canonical fields checks see, how unreadable values are handled, and that prepare receives the partner record.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/145/files#diff-074c5c712914c5d623decfc896e41d16aae926d7c91331dbeac156522727e749'>docs/channels.md</a>
</details>
</dd>
</dl>
</details>
</dd>
</dl>
</details>
<h3>Code Review by Qodo</h3>
<code>🐞 Bugs (1)</code> <code>📘 Rule violations (0)</code> <code>📜 Skill insights (0)</code>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<br/>
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required">
<details>
<summary> 1. Case orders over 150 units now wrongly rejected <code>🐞 Bug</code> <code>≡ Correctness</code></summary>
<br/>
> <details open>
><summary>Description</summary>
><br/>
>
><pre>
><b><i>run()</i></b> overlays <b><i>canonical()</i></b> onto the record that <b><i>check</i></b> sees. For EDI, <b><i>canonical()['quantity']</i></b>
>is total units, which is cases times pack, and this replaces the partner's <b><i>quantity</i></b>.
><b><i>PinecrestChannel.check</i></b> still reads <b><i>record['quantity']</i></b> for its 150 cap, so a line of 13 cases at
>pack 12 (156 units) was accepted before and is now rejected as 'more than 150 ordered'. The cap was
>written for the quantity as ordered, to catch a UPC sent in the quantity field.
></pre>
></details>
> <details>
><summary>Code</summary>
><br/>
>
><code>[portside/channels/base.py[85]](https://github.com/drape-io/crbench-qodo-2026-09/pull/145/files#diff-78e7ffb12e42759f96cc4a39e9c3533434b79aba722678c5e72844d6284233d6R85-R85)</code>
>
>```diff
>+ seen = {**record, **self.canonical(record)} if stage == "check" else record
>```
></details>
> <details>
><summary>Evidence</summary>
><br/>
>
><pre>
>The overlay replaces the EDI <b><i>quantity</i></b> key with units: <b><i>EdiChannel.canonical</i></b> uses
><b><i>units(record['quantity'], uom, pack)</i></b>, which multiplies by <b><i>pack</i></b> when <b><i>uom</i></b> is 'CS'.
><b><i>PinecrestChannel.check</i></b> was not updated and still compares <b><i>parse_quantity(record['quantity'])</i></b> to
><b><i>MAX_QUANTITY</i></b>. The existing test uses 6 cases of 12, which is 72 units and under the cap, so it
>does not catch this.
></pre>
>
> <code>[portside/channels/edi/pinecrest.py\[12-15\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/4ddbc056411914f90ea90ac958c2c9a616f8e224/portside/channels/edi/pinecrest.py/#L12-L15)</code>
> <code>[portside/channels/edi/base.py\[34-40\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/4ddbc056411914f90ea90ac958c2c9a616f8e224/portside/channels/edi/base.py/#L34-L40)</code>
> <code>[portside/channels/fields.py\[15-19\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/4ddbc056411914f90ea90ac958c2c9a616f8e224/portside/channels/fields.py/#L15-L19)</code>
></details>
> <details>
><summary>Agent prompt</summary>
><br/>
>
>```
>The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
>
>## Issue description
>`Channel.run` overlays canonical values on the record passed to `check`. For EDI, canonical `quantity` is total units (cases × pack), which overwrites the partner's ordered `quantity`. `PinecrestChannel.check` still reads `record['quantity']` for its 150 cap, so case lines of more than 150 units are now rejected. They were accepted before.
>
>## Fix Focus Areas
>- portside/channels/edi/pinecrest.py[12-15]
>- portside/channels/base.py[84-86]
>
>## Recommended Fix
>Decide whether the 150 cap applies to the ordered quantity or to total units. If it applies to the ordered quantity, make that explicit: either keep the partner's raw quantity available to `check` under another key, or have the EDI `canonical()` not overwrite it. If the cap should apply to units, change the cap or the test to say so. Add a test with a CS line over 150 units.
>```
> <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code>
></details>
[Dismiss ↗](https://app.qodo.ai/findings/6e1184f4-9006-44b6-a92f-6dd7eb363bde?action=dismiss&origin=git) | [View ↗](https://app.qodo.ai/findings/6e1184f4-9006-44b6-a92f-6dd7eb363bde)
<hr/>
</details>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<!-- qodo-self-review-slot -->
<!-- qodo-context:start -->
<details><summary><strong>Context sources</strong></summary>
<div>Review mode: <code>Auto: ⚖️ Balanced</code>: Cross-cutting canonicalization changes affect framework flow and multiple channel checks.</div>
<!-- qodo-context:end -->
</details>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<!-- qodo-daily-tip:start -->
<details>
<summary><strong>Tip of the day</strong></summary>
<br/>
<pre>💡 Did you know, you can enable the Remediation agent and Qodo fixes findings in a dedicated fix PR</pre>
<a href="https://docs.qodo.ai/tips-and-tricks">More tips ↗</a> | <a href="https://app.qodo.ai/configurations?tab=display-preferences">Customize Qodo ↗</a> | <a href="https://docs.qodo.ai">Qodo docs ↗</a>
</details>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<!-- qodo-daily-tip:end -->
<!-- https://github.com/drape-io/crbench-qodo-2026-09/commit/4ddbc056411914f90ea90ac958c2c9a616f8e224 -->
<a href="https://www.qodo.ai"><img src="https://www.qodo.ai/wp-content/uploads/2025/03/qodo-logo.svg" width="80" alt="Qodo Logo"></a>