-
Notifications
You must be signed in to change notification settings - Fork 1
fix(attachments): align deferred parse budget with import transport #1469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
seonghobae
wants to merge
11
commits into
develop
Choose a base branch
from
feat/naruon-attachment-parse-64m
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
dd1fb33
fix(attachments): align deferred parse budget with import transport
seonghobae 8bd9c0c
docs(adr): keep attachment contract self-contained
seonghobae de6d712
docs(attachments): state bounded parse range
seonghobae 99315f3
fix: fail closed on oversized NewsDOM payloads
seonghobae 575b0c2
refactor: remove unreachable document size branch
seonghobae 09c6ac2
docs: clarify bounded attachment parse range
seonghobae 2cd3aa4
fix(newsdom): classify expected size rejection as info
seonghobae 258ac41
docs(naruon): align pdf dom ADR with current 20MiB contract
seonghobae 1930561
Merge branch 'develop' into feat/naruon-attachment-parse-64m
seonghobae 5b77e7f
Merge branch 'develop' into feat/naruon-attachment-parse-64m
seonghobae 6d6e499
docs(changelog): name both unsupported-binary metadata statuses
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
seonghobae marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # ADR-0005: Bounded PDF DOM upload contract | ||
|
|
||
| **Status:** Proposed | ||
| **Date:** 2026-08-20 | ||
| **Decision owner:** Naruon maintainers | ||
| **Scope:** Signed `POST /api/data/documents/pdf-dom-recognition` uploads | ||
| **Figma File ID:** N/A — backend upload contract; no visual surface. | ||
|
|
||
| ## Context | ||
|
|
||
| Naruon email imports and deferred attachment admission use a 64 MiB bounded | ||
| transport budget. The direct Data workspace PDF-DOM endpoint and its NewsDOM | ||
| sidecar contract remain independently bounded at 20 MiB on the current | ||
| protected branch; this record preserves the proposed alignment without | ||
| claiming that the separate transport change has shipped. | ||
|
|
||
| ## Decision | ||
|
|
||
| Retain the current 20 MiB direct PDF-DOM upload and decoder boundary until the | ||
| separate transport change is reviewed and integrated. Keep the signed-session | ||
| boundary, PDF signature validation, one-byte-over-limit read, base64 | ||
| persistence contract, and `413` response unchanged. A future alignment to the | ||
| 64 MiB import budget requires sidecar confirmation, capacity evidence, and a | ||
| new current-head review; this ADR does not authorize that change. | ||
|
|
||
| ## Consequences | ||
|
|
||
| - Email and manual PDF ingestion currently have explicit, separately governed | ||
| bounded contracts (64 MiB import/deferred admission; 20 MiB direct DOM). | ||
| - Workspace quotas, background-worker limits, and database-capacity monitoring | ||
| remain required because temporary content can be larger. | ||
| - No unbounded upload is introduced; malformed or non-PDF payloads continue to | ||
| fail closed before recognition. | ||
|
|
||
| ## Alternatives rejected | ||
|
|
||
| ### Align the manual endpoint immediately | ||
|
|
||
| Deferred until the sidecar and storage capacity contract are independently | ||
| verified; changing only the Naruon endpoint would create a customer-visible | ||
| failure later in recognition. | ||
|
|
||
| ### Remove the upload limit | ||
|
|
||
| Rejected because request and database resource use must remain bounded at the | ||
| authenticated trust boundary. | ||
|
|
||
| ## References (APA 7th) | ||
|
|
||
| Internet Engineering Task Force. (2022). *HTTP semantics (RFC 9110).* RFC | ||
| Editor. https://www.rfc-editor.org/rfc/rfc9110 | ||
|
|
||
| National Institute of Standards and Technology. (2025). *Secure software | ||
| development framework (SSDF) version 1.2* (NIST Special Publication 800-218 | ||
| Rev. 1, Initial Public Draft). https://doi.org/10.6028/NIST.SP.800-218r1.ipd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # ADR-0006: Bounded attachment parse-source contract | ||
|
|
||
| - **Status:** Accepted for Naruon attachment ingestion | ||
| - **Date:** 2026-08-25 | ||
| - **Figma file ID:** N/A — backend ingestion and evidence contract; no UX surface | ||
| - **Owners:** Naruon ingestion and data-quality maintainers | ||
|
|
||
| ## Context | ||
|
|
||
| Naruon accepts authenticated email imports up to 64 MiB, while the deferred | ||
| attachment parser previously rejected source payloads above 20 MiB. That split | ||
| made a valid upload fail later in parsing and prevented a customer from knowing | ||
| whether a file was rejected by transport, parser admission, or an unsupported | ||
| format. Unsupported binaries are intentionally not parsed inline and must remain | ||
| metadata-only until a separately reviewed parser is available. | ||
|
|
||
| ## Decision | ||
|
|
||
| Use one 64 MiB upper bound for attachment source bytes retained for a deferred | ||
| recognition worker. The parser continues to: | ||
|
|
||
| 1. accept only the existing authenticated import transport; | ||
| 2. retain validated PDF bytes only for the deferred NewsDOM path; | ||
| 3. return `parse_size_limit_exceeded` without raw content above 64 MiB; | ||
| 4. return `unsupported_content_type` with `unsupported_binary` and no raw bytes | ||
| for an unparseable content type; and | ||
| 5. preserve the parser key, parse status, and error code for the Data quality | ||
| evidence surface. | ||
|
|
||
| This is a bounded admission contract, not a promise that every binary format | ||
| is parseable. Adding a new parser requires its own dependency, sandbox, | ||
| provenance, and regression review. | ||
|
|
||
| ## Consequences | ||
|
|
||
| - Attachments larger than 20 MiB and no larger than 64 MiB can reach deferred | ||
| recognition consistently with the import transport. | ||
| - A 64 MiB raw source can expand when base64-encoded in the existing deferred | ||
| content column; the database/object-lifecycle work must move this payload to | ||
| object storage before materially increasing the bound again. | ||
| - Unsupported binaries remain visible in scoped quality counts without exposing | ||
| their bytes, identifiers, or provider content. | ||
| - The contract is independent of any Figma design and has no Storybook scene. | ||
|
|
||
| ## Verification | ||
|
|
||
| - `backend/tests/test_attachment_parser.py` asserts the 64 MiB boundary is | ||
| above the former 20 MiB parser limit and preserves unsupported-binary | ||
| metadata-only behavior. | ||
| - The import transport remains covered by | ||
| `backend/tests/test_email_import_service.py`. | ||
| - The PDF DOM upload contract is being integrated separately by stacked PR | ||
| #1427; this ADR governs the attachment-parser source budget and remains | ||
| valid if that transport change is merged independently. | ||
|
|
||
| ## References (APA 7th) | ||
|
|
||
| Fielding, R. T., Nottingham, M., & Reschke, J. (Eds.). (2022). *HTTP | ||
| semantics* (RFC 9110). Internet Engineering Task Force. | ||
| https://www.rfc-editor.org/rfc/rfc9110.html | ||
|
|
||
| Souppaya, M., Scarfone, K., & Dodson, D. (2022). *Secure software development | ||
| framework (SSDF) version 1.1: Recommendations for mitigating the risk of | ||
| software vulnerabilities* (NIST Special Publication 800-218). National Institute | ||
| of Standards and Technology. https://doi.org/10.6028/NIST.SP.800-218 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
docs/doctoring/bounded-attachment-parse-source-contract.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Bounded attachment parse-source contract | ||
|
|
||
| ## Customer outcome | ||
|
|
||
| An email attachment between 20 MiB and 64 MiB is not rejected by a hidden | ||
| parser-only limit after transport admission. The Data workspace still reports | ||
| unsupported formats explicitly, so the next action is to add a reviewed parser | ||
| or use the original provider file rather than treating metadata as extracted | ||
| content. | ||
|
|
||
| ## Contract | ||
|
|
||
| `MAX_ATTACHMENT_PARSE_SOURCE_BYTES` is 64 MiB, matching the authenticated email | ||
| import budget. The parser is fail-closed: | ||
|
|
||
| - supported text formats are parsed inline within the existing character bound; | ||
| - PDF bytes are retained only for bounded deferred NewsDOM recognition; | ||
| - unsupported binary formats return `unsupported_content_type`, | ||
| `unsupported_binary`, and empty content; | ||
| - oversized source bytes return `parse_size_limit_exceeded` and empty content. | ||
|
|
||
| This preserves provenance without claiming that an unsupported file was parsed. | ||
| The quality surface exposes the parser key and status, not raw attachment bytes, | ||
| message IDs, attachment IDs, credentials, or customer payloads. | ||
|
|
||
| ## Evidence and next action | ||
|
|
||
| The parser boundary is tested in | ||
| `backend/tests/test_attachment_parser.py`. The import transport is tested in | ||
| `backend/tests/test_email_import_service.py`. If a customer needs a currently | ||
| unsupported format, add a dedicated parser proposal with sandbox, dependency, | ||
| provenance, and exact-head regression evidence before changing the registry. | ||
|
|
||
| ## Research traceability | ||
|
|
||
| The bounded transport and fail-closed error contract are aligned with HTTP | ||
| representation semantics (Fielding et al., 2022) and secure development | ||
| verification practices (Souppaya et al., 2022). See | ||
| [`ADR-0006`](../adr/0006-bounded-attachment-parse-source-contract.md). |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.