Repository navigation
fix(epcis): keep a truncated export truncated when the fallback adds nothing; close the #3714 review leftovers - #3767
PetrefiedThunder wants to merge 3 commits into
Conversation
…nothing, and close the #3714 review leftovers Ten CodeRabbit threads were left open when #3714 (EPCIS export cap, FDA package evidence context) merged. Each was verified against main first. services/ingestion/app/epcis/router.py (GET /api/v1/epcis/export) - A truncated database page that the product_id filter emptied entered the in-memory fallback branch and had its regengine:limit / regengine:truncated reset to null / false, so an incomplete export read as complete. The reset now happens only when the fallback actually supplies events; when it supplies nothing the database page's facts stand. - The fallback returned store iteration order while advertising "event_timestamp desc". Fallback records are now sorted by their stored event time, newest first, undated records last. services/shared/rules/versions.py - Each snapshot read runs on its own SAVEPOINT (begin_nested) when the session supports it, so a failed catalog read cannot leave the caller's transaction in InFailedSqlTransaction and poison the evaluated read and every later query on that session. Fake sessions without begin_nested run the statement directly, as before. services/shared/request_workflow/assembly.py - package_contents carries rule_versions_status (the snapshot's catalog_status, "unavailable" when absent) beside rule_versions, so an empty catalog that was read stays distinguishable from one that could not be read; the status is hashed with the rest of the package. Docs - docs/PRODUCT_DESCRIPTION.md names the real cutoff field (regengine:truncated inside regengine:metadata). - docs/runbooks/FDA_RECALL_RESPONSE.md tells reviewers to check catalog_status / evaluated_status before treating rule-version evidence as complete, documents the 250-entry cap behind VALIDATION_ERRORS and the known_gaps fields that say when it bit, and qualifies the package integrity sentence: the verifiers prove internal consistency against manifest.json, not the issuer; compare X-Package-Hash to tie a ZIP to the original export. Tests - epcis router: truncated page emptied by the filter stays truncated with the limit; fallback events come back newest first with undated last. - rule_versions: a failing catalog read is rolled back on its own savepoint and the evaluated read still runs on a second one. - request workflow: rule_versions_status is "ok" for an empty readable catalog and "unavailable" when the catalog read fails. - recall package: the snapshot helper receives (session, tenant, events) and its return value is forwarded as rule_versions. - proof verifier and admin verifier: a same-size edit inside evidence_context is rejected by the hash check, not the size check. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GyhDYG3ddQvVKyu2qtYfCj
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
PR Blocker ChecklistHead SHA: Status: Ready
|
…n-8fijxh-s3-s7-followup
The Security Audit, Production Readiness Gate and per-service pip-audit jobs went red on this PR after advisories for pypdf 6.21.2, pyasn1 0.6.4 and follow-redirects 1.16.0-1.16.1 were published. Main is red on the same jobs. This ports #3773 byte for byte (pypdf 6.21.4, pyasn1 0.6.5, npm overrides follow-redirects >=1.16.2 and minimatch >=11.0.1). It no-ops once main carries #3773. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GyhDYG3ddQvVKyu2qtYfCj
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Status 14:12 UTC: ea0ce2f is green on every required check ( The first Original report on 961487f: red on dependency audits, not on this PR's code. Fix ported in ea0ce2f. Failing checks on 961487f:
Why it is not this PR's: this PR changes no dependency file. The advisories were published after the last green main run. Main 1d9c995 carries the same pins ( What I pushed:
Local checks on ea0ce2f:
Generated by Claude Code |
|
Vercel preview: https://regengine-6jg40nlr8-petrefiedthunders-projects.vercel.app Access is via Vercel login (Deployment Protection). |
✅ Bundle Size Report
Bundle is within the 10.0MB limit. |
Summary
Closes the ten CodeRabbit threads left open when #3714 (S3 EPCIS export cap, S7 FDA package evidence context) merged. Each was verified against main before changing anything. Lane: backend (export).
GET /api/v1/epcis/exportinservices/ingestion/app/epcis/router.py: when the database page was truncated and theproduct_idfilter emptied it, the in-memory fallback branch resetregengine:limit/regengine:truncatedtonull/false. The reset now happens only when the fallback actually supplies events; otherwise the database page's facts stand.event_timestamp desc; it now sorts by the stored event time, newest first, undated records last.snapshot_rule_versionsinservices/shared/rules/versions.pyruns each read on its ownbegin_nested()savepoint when the session supports it, so a failed catalog read cannot leave the caller's transaction inInFailedSqlTransactionand poison the evaluated read and later queries. Fake sessions withoutbegin_nestedrun the statement directly.rule_versions_statusin the request-workflow package.services/shared/request_workflow/assembly.pystores the snapshot'scatalog_status(defaultunavailable) besiderule_versionsinpackage_contents, so an empty catalog that was read stays distinguishable from one that could not be read; it is hashed with the rest of the package.docs/PRODUCT_DESCRIPTION.mdnames the real cutoff field (regengine:truncatedinsideregengine:metadata).docs/runbooks/FDA_RECALL_RESPONSE.md: checkcatalog_status/evaluated_statusbefore treating rule-version evidence as complete; the 250-entry cap behindVALIDATION_ERRORS_*.logand theknown_gaps.missing_required_events_truncated/missing_required_events_listedfields; the integrity sentence now says the verifiers prove internal consistency againstmanifest.json, not the issuer, and points toX-Package-Hash.rule_versions_statusokvsunavailable; recall package forwards the snapshot helper's result and arguments; proof and admin verifiers reject a same-size edit ofevidence_contexton the hash, not the size.Thread map (all on #3714): docs/PRODUCT_DESCRIPTION.md L34 (field name); FDA_RECALL_RESPONSE.md L168 (statuses), L169 (250 cap), L174-175 (integrity wording); epcis/router.py L371-372 (Major, truncation reset) and L397 (ordering); test_fda_export_recall_1342.py L435-437 (stub the snapshot helper); test_proof_verify_router.py L977-978 and the admin verifier test (same-size mutation); assembly.py L161-163 (
rule_versions_status); versions.py L75-86 (savepoints).Type of Change
Test Plan
Run locally, all green:
python3 scripts/security/scan_tenant_scope.py # the pinned EPCIS query text is unchanged python3 scripts/check_docs_links.py python3 scripts/check_trust_safety_copy.pyPlus
ruff check --select I,E9,F63,F7,F82on the changed files andgit diff --check.Checklist
sys.modules[X] = stub, I justified it in the PR description (none)Related Issues
Relates to #3714 (its ten open review threads) and #3701 (stories S3 and S7).
Generated by Claude Code