crbench//

← all cases

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

d1 · correctness · high · portside/channels/edi/pinecrest.py:19
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 project's history shows the habit the diff breaks: each earlier change to how run() calls the stages (stripping text fields before them, running them from the `stages` list, keeping one channel instance per process) changed, in the same commit, the channels that depended on the old behaviour (Kestrel's PO-length check for the stripping, Tillwise's per-file state for the shared instance).

The change under review

diff
diff --git a/docs/channels.md b/docs/channels.md
index 75b80b3..3c4d61a 100644
--- a/docs/channels.md
+++ b/docs/channels.md
@@ -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")`.
diff --git a/portside/channels/api/cobalt.py b/portside/channels/api/cobalt.py
index dcfd1df..307781f 100644
--- a/portside/channels/api/cobalt.py
+++ b/portside/channels/api/cobalt.py
@@ -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")
diff --git a/portside/channels/base.py b/portside/channels/base.py
index ba794db..d222bb8 100644
--- a/portside/channels/base.py
+++ b/portside/channels/base.py
@@ -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:
diff --git a/portside/channels/marketplace/orchard_row.py b/portside/channels/marketplace/orchard_row.py
index 1114272..b784e34 100644
--- a/portside/channels/marketplace/orchard_row.py
+++ b/portside/channels/marketplace/orchard_row.py
@@ -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")
diff --git a/portside/channels/marketplace/vendora.py b/portside/channels/marketplace/vendora.py
index ee1b26e..a1d6c5f 100644
--- a/portside/channels/marketplace/vendora.py
+++ b/portside/channels/marketplace/vendora.py
@@ -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")
diff --git a/portside/channels/storefront/copperleaf.py b/portside/channels/storefront/copperleaf.py
index a562acc..cef4740 100644
--- a/portside/channels/storefront/copperleaf.py
+++ b/portside/channels/storefront/copperleaf.py
@@ -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}")
diff --git a/portside/channels/storefront/fernhill.py b/portside/channels/storefront/fernhill.py
index a796875..72ff639 100644
--- a/portside/channels/storefront/fernhill.py
+++ b/portside/channels/storefront/fernhill.py
@@ -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")
diff --git a/portside/channels/wholesale/bellwether.py b/portside/channels/wholesale/bellwether.py
index 3deb05f..1842b3d 100644
--- a/portside/channels/wholesale/bellwether.py
+++ b/portside/channels/wholesale/bellwether.py
@@ -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")
diff --git a/portside/channels/wholesale/tamsin.py b/portside/channels/wholesale/tamsin.py
index 7777142..8a0ee0d 100644
--- a/portside/channels/wholesale/tamsin.py
+++ b/portside/channels/wholesale/tamsin.py
@@ -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")
diff --git a/tests/channels/test_base.py b/tests/channels/test_base.py
index c01f4f0..a26469f 100644
--- a/tests/channels/test_base.py
+++ b/tests/channels/test_base.py
@@ -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.

#BotResultCaughtCoverageFindingsFalse alarms
1 Claude Code (Opus 5.5) solved 1/1 100.0% 1 0
2 cursor solved 1/1 100.0% 1 0
3 Drape (Deep Review) solved 1/1 100.0% 1 0
4 Drape (Review) solved 1/1 100.0% 1 0
5 greptile solved 1/1 100.0% 1 0
6 Mjolnir (Opus 5.5) solved 1/1 100.0% 2 0
7 Mjolnir (Sonnet 5.5) solved 1/1 100.0% 2 0
8 qodo solved 1/1 100.0% 1 0
9 Cubic miss 0/1 0.0% 0 0

Bot results

Claude Code (Opus 5.5) · cross-file engine bifrost 0.11.0
DefectSeverityFoundGrade
d1 high ✓ exact
valid · matches d1 · impact high
raw comments (1)
portside/channels/base.py:85
check() now gets `{**record, **self.canonical(record)}`, so canonical values replace partner fields that share a name. EDI's canonical `quantity` is `units(quantity, uom, pack)`: for a case line (uom CS) that is cases × pack, and it replaces the partner's `quantity`, which is the number of cases ordered. PinecrestChannel.check (portside/channels/edi/pinecrest.py) was not changed and still runs `parse_quantity(record["quantity"]) > MAX_QUANTITY`. That check is meant to cap the quantity as ordered, but it now sees units. Example: a valid line of 20 cases with pack 12 is now rejected as 'more than 150 ordered' (240 > 150), so legitimate case orders are dropped. EdiChannel.check has a related problem: its `canonical(record, strict=True)` validation now runs on the already-multiplied quantity, giving units(cases×pack, CS, pack). Any check that reads a partner field whose name matches a canonical key (`quantity`, `sku`, `currency`, `email`) now silently gets the canonical meaning instead.
Cubic · cross-file engine bifrost 0.11.0
DefectSeverityFoundGrade
d1 high ✗ —
raw comments (1)
PR-level
<!-- 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/144?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/144?returnTo=https%3A%2F%2Fgithub.com%2Fdrape-io%2Fcrbench-cubic-2026-09%2Fpull%2F144) | [Re-trigger cubic](https://www.cubic.dev/action/re-review/pr/drape-io/crbench-cubic-2026-09/144/ai_pr_review_github_delivery_96e55a5cbea47cedf1be89570f7732d3436d487358ed38f36f3c893272e88a8c?returnTo=https%3A%2F%2Fgithub.com%2Fdrape-io%2Fcrbench-cubic-2026-09%2Fpull%2F144)</sub> <!-- cubic:review-post:ai_pr_review_github_delivery_96e55a5cbea47cedf1be89570f7732d3436d487358ed38f36f3c893272e88a8c:a20a60ad2a020a22102c4422ceb75007f755a6c0:25254b5b-6487-510e-b0ce-36dc76aa8f73 -->
cursor · cross-file engine bifrost 0.11.0
DefectSeverityFoundGrade
d1 high ✓ exact
valid · matches d1 · impact high
raw comments (2)
portside/channels/base.py:86
### EDI overlay misreads ordered quantity **High Severity** <!-- DESCRIPTION START --> `run` overlays canonical `quantity` onto the record `check` sees. For EDI that value is unit count, cases times pack, not the ordered PO quantity. `PinecrestChannel` still applies its 150 cap to `quantity`, so a case line whose units exceed 150 is rejected even when the ordered amount is under the cap. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: e096c5eb-13a0-4886-94ff-4a6e9316404e --> <!-- LOCATIONS START portside/channels/base.py#L84-L86 LOCATIONS END --> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjMwODczNWM3LTEyMjYtNDJjMS1iZDM5LTM3MzMzMTBiNDU4OCIsImVuY3J5cHRpb25LZXkiOiJDMXRsSUdqaERUTHlHU2g1SDFJSzQteTFBS2JrU0RJZ1VWX3FWUWhzWEFBIiwiYnJhbmNoIjoicHItYWNkN2UzYjQwOCIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJvdmlkZXIiOiJnaXRodWIifX0" 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>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjMwODczNWM3LTEyMjYtNDJjMS1iZDM5LTM3MzMzMTBiNDU4OCIsImVuY3J5cHRpb25LZXkiOiJDMXRsSUdqaERUTHlHU2g1SDFJSzQteTFBS2JrU0RJZ1VWX3FWUWhzWEFBIiwiYnJhbmNoIjoicHItYWNkN2UzYjQwOCIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJOdW1iZXIiOjE0NCwiY29tbWl0U2hhIjoiODQ0Nzk2YTJhMmE0MzQ0OGE0ZGU5YTRmZmRmMWQzYzY5N2ViNmZlMiIsInByb3ZpZGVyIjoiZ2l0aHViIn19" 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 844796a2a2a43448a4de9a4ffdf1d3c697eb6fe2. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
PR-level
<!-- 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=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTpjYWQyOGRjNy0xODZhLTRlNDctYmYwMS0zZjNkNGRmY2FkODEiLCJlbmNyeXB0aW9uS2V5IjoiWV91cHZtdktBclF5elVsS0Z3TUtvX0FLQWc0cXFiSG9Yc2V2aW1BM3dicyIsImJyYW5jaCI6InByLWFjZDdlM2I0MDgiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" 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 844796a2a2a43448a4de9a4ffdf1d3c697eb6fe2. 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
DefectSeverityFoundGrade
d1 high ✓ exact
valid · matches d1 · impact high
raw comments (1)
portside/channels/base.py:85
**Pinecrest rejects legitimate case orders** `check` now sees EDI `quantity` as cases × pack size, not the quantity ordered, so 20 cases of 12 becomes 240 and trips Pinecrest's limit of 150. Don't put the EDI unit count over the partner's `quantity` field, or have Pinecrest check 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/pinecrest.py:10 """Pinecrest's buyers' system has sent an item's UPC in the quantity field of a PO line, portside/channels/edi/pinecrest.py:11 which would ship a store a warehouse's worth of stock. No store orders more than portside/channels/edi/pinecrest.py:12 MAX_QUANTITY of anything on one line, so a line over it goes back to the buyer.""" portside/channels/edi/pinecrest.py:14 name = "pinecrest" portside/channels/edi/pinecrest.py:15 MAX_QUANTITY = 150 portside/channels/edi/pinecrest.py:17 def check(self, record: Record) -> None: portside/channels/edi/pinecrest.py:18 super().check(record) ```
Drape (Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ exact
valid · matches d1 · impact high
raw comments (1)
portside/channels/base.py:85
**Pinecrest cap now compares units, not ordered quantity** The overlay replaces the partner's `quantity` with the canonical unit count (cases × pack) before `check` runs. Pinecrest's cap on `record["quantity"]` now fires on legitimate case orders. Don't overlay `quantity` where it changes meaning (EDI), or have Pinecrest check the ordered quantity explicitly. ``` 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/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 portside/channels/edi/pinecrest.py:19 if parse_quantity(record["quantity"]) > self.MAX_QUANTITY: ```
greptile · cross-file engine bifrost 0.11.0
DefectSeverityFoundGrade
d1 high ✓ exact
valid · matches d1 · impact high
raw comments (2)
portside/channels/base.py:85
<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 order limit from cases ordered to individual units. For example, `quantity="13"`, `uom="CS"`, and `pack="12"` becomes `quantity=156` before `PinecrestChannel.check`, so it rejects the line as "more than 150 ordered". Previously it compared 13 and imported 156 units. Preserve the partner's ordered quantity for this check and add a case-order regression test.
PR-level
<!-- greptile_summary --> <h2><a href="https://app.greptile.com/api/retrigger?id=87707312"><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/144"><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 checks across the order\-import workflow\. Fix Pinecrest's case-order limit before merging; valid orders can now be rejected. <h2>Findings</h2> 1. <img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top">&nbsp;**Valid case orders get rejected** <a href="https://github.com/drape-io/crbench-greptile-2026-09/pull/144#discussion_r4371631984">▶</a> <h3>Summary</h3> Checks now receive canonical SKU, quantity, currency, and email values while `prepare` still receives the partner's record. - Channel checks now compare partner orders using shared canonical fields. - Vendora and Bellwether checks use the shared SKU value. - Currency checks compare the shared canonical currency. - Fernhill checks staff orders using the shared email value. <details open><summary><h3>Diagram</h3></summary> ```mermaid %%{init: {'theme': 'neutral'}}%% flowchart TD A[Partner record after earlier stages] --> B[Read canonical values] A --> C[Keep partner record] B --> D[Overlay values for check] D --> E{Check result} E -->|Accept| F[Prepare partner record] C --> F E -->|Skip or reject| G[Count and stop this line] F --> H[Write 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/3c7376bb6d93930f564832441b700f17ae695446) · [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
DefectSeverityFoundGrade
d1 high ✓ off by one
valid · impact high
EdiChannel.canonical sets quantity=units(quantity, uom, pack), which is ordered × pack for CS lines. The change now writes that value over the partner's quantity before check runs. Unchanged PinecrestChannel.check runs parse_quantity(record["quantity"]) > MAX_QUANTITY (150), so a line of 20 cases with a pack of 12 is now compared as 240 and rejected. The finding's point about the strict canonical call multiplying by the pack again is accurate but does no extra harm, because that call only rejects values it can't read. The main failure stands. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d1 · impact high
raw comments (2)
portside/channels/base.py:84
[P2] Pinecrest's quantity cap now applies to units, not the quantity as ordered Before `check` runs, `run()` now writes `self.canonical(record)` over the partner's fields. For EDI channels, `EdiChannel.canonical` returns `quantity=units(record["quantity"], uom, pack)`. That replaces the partner's `quantity` field (the amount ordered, in the line's unit of measure) with ordered × pack whenever uom is CS. `PinecrestChannel.check`, which this PR doesn't change, still runs `parse_quantity(record["quantity"]) › self.MAX_QUANTITY`, so it now compares against units. A normal case line such as quantity "20", uom "CS", pack "12" was accepted before and is now rejected as "more than 150 ordered" (240 › 150). Every Pinecrest case line whose units come to more than 150 is affected. The family's own `check` also calls `self.canonical(record, strict=True)` on this overlaid record, so its strict validation multiplies by the pack a second time. Pinecrest's check was never moved to the new semantics, and no test covers it.
portside/channels/base.py:84
[P2] Pinecrest's quantity cap now applies to units, not the quantity ordered The new pre-check overlay sets `canonical()` values over the partner fields that have the same name. For the EDI family, `canonical()["quantity"]` is `units(quantity, uom, pack)`: the case count times the pack size. That replaces the partner's `quantity` field, which the EDI docstring describes as the amount "as ordered, in the line's unit of measure". `PinecrestChannel.check` still runs `parse_quantity(record["quantity"]) › MAX_QUANTITY`, so it now compares expanded units against the 150 cap instead of the ordered quantity. The cap is there to catch a UPC sent in the quantity field. Ordinary case lines now get rejected as "more than 150 ordered", for example `quantity: "13", uom: "CS", pack: "12"` (156 units), which this code accepted before. The existing test only uses 6×12=72, so it doesn't catch this. Other EDI subclasses that read `record["quantity"]` in `check` would see the same changed meaning.
Mjolnir (Sonnet 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ off by one
valid · matches d1 · impact high
valid · impact high
For EDI, canonical()'s quantity is units(quantity, uom, pack), which is cases × pack on a CS line. The new overlay puts that value over record['quantity'] before check runs, so PinecrestChannel.check's `parse_quantity(record["quantity"]) > self.MAX_QUANTITY` now compares units rather than the quantity ordered. A CS line with quantity 10 and pack 24 now gets rejected (240 > 150) when it used to pass. The claim that the multiplier is applied a second time in the strict canonical call is also accurate, though that part does no harm today. [grounded: diff] [consensus 3/3: valid=3]
raw comments (2)
portside/channels/base.py:84
[P2] EDI check now sees case-expanded quantity, changing Pinecrest's limit The new overlay `{**record, **self.canonical(record)}` replaces the partner's `quantity` with the canonical value before every `check`. For EDI channels, `EdiChannel.canonical` returns `units(quantity, uom, pack)`, which multiplies cases by pack size, so the field changes meaning. `PinecrestChannel.check` (portside/channels/edi/pinecrest.py) still does `parse_quantity(record["quantity"]) › MAX_QUANTITY`. That check used to compare the quantity as the partner sent it. It now compares the expanded unit count. A line of 20 cases with pack 12 was accepted (20 ≤ 150). It is now rejected as "more than 150 ordered" (240 › 150). `EdiChannel.check`'s own strict `canonical(record)` call also runs `units()` on the already-expanded quantity, so it expands twice. The `check` sites that were converted compare only sku and currency, where the overlay is a plain normalization. Pinecrest and Tessera were not converted. Either `Pinecrest` needs to read the partner's quantity explicitly, or the overlay must not rewrite fields whose canonical meaning differs from the partner's.
portside/channels/base.py:84
[P1] Overlay changes EDI `quantity` that Pinecrest's check reads For the EDI family, `canonical()` returns `quantity` as total units (cases × pack for `CS` lines), and this overlay now replaces the partner's `quantity` with that value before every `check`. `PinecrestChannel.check` (portside/channels/edi/pinecrest.py) still does `parse_quantity(record["quantity"]) › MAX_QUANTITY`, and that limit is meant for the ordered quantity on the line, as its docstring says. It now compares units instead. Example: a `CS` line with `quantity="10"` and `pack="24"` used to pass (10 ≤ 150) and is now rejected as "more than 150 ordered" (240 › 150). Every Pinecrest case line with a large pack size is wrongly rejected, so valid orders are silently dropped. The same overlay also feeds `EdiChannel.check`'s strict `canonical(record)` call a quantity that is already in units, so it re-applies the case multiplier. That second effect is harmless today. The fix is either to not overlay `quantity` where it differs in meaning from the partner field, or to update `PinecrestChannel.check` to compare the correct value. The new docs and tests only cover families where `quantity` is a plain int parse, so they don't catch this
qodo · cross-file engine bifrost 0.11.0
DefectSeverityFoundGrade
d1 high ✓ exact
valid · matches d1 · impact high
raw comments (3)
portside/channels/base.py:86
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 1\. Pinecrest rejects valid case orders <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>Channel.run</i></b> replaces Pinecrest&#x27;s ordered <b><i>quantity</i></b> with the canonical unit count before <b><i>PinecrestChannel.check</i></b> applies its 150-item limit. For a line ordering 13 cases of 12 units, the check now compares 156 against the limit instead of the partner&#x27;s 13, rejecting a line it previously imported. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description The canonical overlay replaces the EDI partner's ordered case count with a unit count before Pinecrest checks its limit, causing valid case orders to be rejected. ## Fix Focus Areas - portside/channels/base.py[84-86] - portside/channels/edi/pinecrest.py[14-20] ## Recommended Fix Keep the partner's ordered quantity available separately when overlaying canonical fields, and have Pinecrest apply its existing limit to that original quantity rather than the unit-expanded canonical quantity. Add a case-order test whose ordered case count is below 150 but whose unit count exceeds 150. ``` <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/f4b1895d-42b8-4503-9266-9b82fed3bbf2?action=dismiss&origin=git) | [View ↗](https://app.qodo.ai/findings/f4b1895d-42b8-4503-9266-9b82fed3bbf2)
PR-level
<h3>PR Summary by Qodo</h3> Let channel checks compare canonical fields <code>🐞 Bug fix</code> <code>✨ Enhancement</code> <code>🧪 Tests</code> <code>📝 Documentation</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 field values so partner casing and formatting cannot bypass import rules. >• Remove channel-specific normalization that had drifted from preparation behavior. >• Preserve partner records for preparation and document the stage contract. ></pre> </dd> </dl> </details> <details> <summary>Diagram</summary> <dl> <dd> <br/> ```mermaid graph TD raw["Partner record"] --> strip["Strip text"] --> decode["Decode if API"] --> overlay["Canonical overlay"] --> check{"Check rules"} -- "accepted" --> prepare["Prepare original"] --> sink["Canonical sink"] decode -. "partner record" .-> prepare ``` </dd> </dl> </details> <details> <summary>High-Level Assessment</summary> <dl> <dd> <br/> >The following are alternative approaches to this PR: <details> <summary><b>1. Pass canonical fields as a separate check argument</b></summary> <dl> <dd> - ➕ Makes the distinction between partner data and comparison values explicit. - ➖ Changes the check contract and requires migrating channel implementations. </dd> </dl> </details> >**Recommendation:** Keep the check-only overlay: it centralizes comparison values without changing existing check signatures or the record passed to prepare. A separate argument would make the boundary more explicit, but its migration cost is disproportionate here. </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> >• Passes checks a copy of the stage record overlaid with readable canonical values. Leaves the record used by prepare unchanged and documents that distinction. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/144/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>Compare Cobalt&#x27;s canonical currency</code> <code>+1/-1</code></summary> <br/> >Compare Cobalt&#x27;s canonical currency > ><pre> >• Checks the canonical currency instead of the partner&#x27;s currencyCode, allowing casing accepted by preparation. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/144/files#diff-0ea8e8c8557d45b0498eef4f385e286b2e5998b715dda59756de615ff0db525a'>portside/channels/api/cobalt.py</a> </details> <details> <summary>bellwether.py<code>Reject discontinued canonical SKUs</code> <code>+1/-1</code></summary> <br/> >Reject discontinued canonical SKUs > ><pre> >• Compares canonical SKUs with the discontinued set, including partner SKUs whose surrounding spaces previously prevented a match. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/144/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&#x27;s canonical currency</code> <code>+1/-1</code></summary> <br/> >Check Orchard Row&#x27;s canonical currency > ><pre> >• Uses the family-provided currency value for its GBP restriction instead of normalizing the nested partner field locally. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/144/files#diff-64a452b364dcda6d10c283447cf5ea5c1951d85310c5312a2f22042ba7782811'>portside/channels/marketplace/orchard_row.py</a> </details> <details> <summary>vendora.py<code>Identify samples using canonical SKUs</code> <code>+1/-6</code></summary> <br/> >Identify samples using canonical SKUs > ><pre> >• Uses the canonical SKU, which already has Vendora&#x27;s prefix removed, to skip free samples. Removes duplicated SKU normalization. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/144/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 canonical currency without applying a separate uppercase conversion. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/144/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> >• Matches the staff domain against the normalized email rather than lowercasing it within the channel. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/144/files#diff-00d7304aead1485f8eb3904a607dc39b50c26630c2e27a86f367c6470acb1607'>portside/channels/storefront/fernhill.py</a> </details> <details> <summary>tamsin.py<code>Check Tamsin&#x27;s canonical currency</code> <code>+1/-1</code></summary> <br/> >Check Tamsin&#x27;s canonical currency > ><pre> >• Uses the family-provided currency for the EUR restriction instead of normalizing the partner field locally. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/144/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 canonical check views and preparation handoff</code> <code>+52/-0</code></summary> <br/> >Test canonical check views and preparation handoff > ><pre> >• Covers canonical values replacing partner values during checks, preservation of unreadable partner values, and delivery of the original stage record to prepare. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/144/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 view</code> <code>+6/-2</code></summary> <br/> >Document the check-only canonical view > ><pre> >• Explains which canonical fields checks receive, 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/144/files#diff-074c5c712914c5d623decfc896e41d16aae926d7c91331dbeac156522727e749'>docs/channels.md</a> </details> </dd> </dl> </details> </dd> </dl> </details>
PR-level
<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. Pinecrest rejects valid case orders <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>Channel.run</i></b> replaces Pinecrest&#x27;s ordered <b><i>quantity</i></b> with the canonical unit count before ><b><i>PinecrestChannel.check</i></b> applies its 150-item limit. For a line ordering 13 cases of 12 units, the >check now compares 156 against the limit instead of the partner&#x27;s 13, rejecting a line it previously >imported. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[portside/channels/base.py[R85-86]](https://github.com/drape-io/crbench-qodo-2026-09/pull/144/files#diff-78e7ffb12e42759f96cc4a39e9c3533434b79aba722678c5e72844d6284233d6R85-R86)</code> > >```diff >+ seen = {**record, **self.canonical(record)} if stage == "check" else record >+ out = getattr(self, stage)(seen) >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The new overlay overwrites the partner&#x27;s <b><i>quantity</i></b> before check. EDI canonicalization multiplies a >case count by its pack size, while Pinecrest compares the resulting <b><i>record[&quot;quantity&quot;]</i></b> to 150; the >existing case-order test confirms that six cases of twelve produce a canonical quantity of 72. ></pre> > > <code>[portside/channels/base.py\[81-88\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/193826485c3be88f11fb75fc9bf974e391d16580/portside/channels/base.py/#L81-L88)</code> > <code>[portside/channels/edi/base.py\[1-8\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/193826485c3be88f11fb75fc9bf974e391d16580/portside/channels/edi/base.py/#L1-L8)</code> > <code>[portside/channels/edi/base.py\[31-38\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/193826485c3be88f11fb75fc9bf974e391d16580/portside/channels/edi/base.py/#L31-L38)</code> > <code>[portside/channels/fields.py\[14-18\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/193826485c3be88f11fb75fc9bf974e391d16580/portside/channels/fields.py/#L14-L18)</code> > <code>[portside/channels/edi/pinecrest.py\[10-20\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/193826485c3be88f11fb75fc9bf974e391d16580/portside/channels/edi/pinecrest.py/#L10-L20)</code> > <code>[tests/channels/test_pinecrest.py\[4-29\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/193826485c3be88f11fb75fc9bf974e391d16580/tests/channels/test_pinecrest.py/#L4-L29)</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 >The canonical overlay replaces the EDI partner's ordered case count with a unit count before Pinecrest checks its limit, causing valid case orders to be rejected. >## Fix Focus Areas >- portside/channels/base.py[84-86] >- portside/channels/edi/pinecrest.py[14-20] >## Recommended Fix >Keep the partner's ordered quantity available separately when overlaying canonical fields, and have Pinecrest apply its existing limit to that original quantity rather than the unit-expanded canonical quantity. Add a case-order test whose ordered case count is below 150 but whose unit count exceeds 150. >``` > <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/f4b1895d-42b8-4503-9266-9b82fed3bbf2?action=dismiss&origin=git) | [View ↗](https://app.qodo.ai/findings/f4b1895d-42b8-4503-9266-9b82fed3bbf2) <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 runtime behavior changes affect every channel&#x27;s check and prepare flow.</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/193826485c3be88f11fb75fc9bf974e391d16580 --> <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>