Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR preserves detected binary formats and validates inferred UTF-16 before including attachment contents as text. Example: Send a 159,744-byte SQLite database named t.db with application/octet-stream content type.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open: it addresses a concrete current bug through the existing classification owner, and no safely landable replacement is established. Priority: P1 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherMedia-core classifies attachment bytes and MIME hints; attachment caching passes that classification to document admission and extraction, which produce model-visible file blocks. flowchart TD
A[Inbound attachment] --> B[Media attachment cache]
B --> C[Media core classifier]
C --> D[Document admission]
D --> E[Text or PDF extraction]
D --> F[Unsupported format marker]
E --> G[Model context]
F --> G
Technical reviewBest possible solution: Keep authoritative binary detections out of text inference in media-core while preserving existing text decoders and attachment access. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the binary-to-text path, and the linked report supplies official-release steps; this read-only review ran no target code. Is this the best way to solve the issue? The patch repairs the existing shared owner, distinguishes byte signatures from MIME hints, and validates unknown UTF-16 candidates without adding parallel policy or configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1b9518af272b. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +14, Tests +82. Total +96 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 13, 2026, 9:37 AM ET / 14:37 UTC. |
|
Thanks @ARAYN7011 for working on #198289. We landed #198309 (afa871c), the earliest of the three fixes, which keeps an attachment binary when its magic bytes match the resolved type and leaves the BOM, extension and text-hint paths unchanged. Closing this one as a duplicate; your work helped confirm the cause. |
Closes #198289
What Problem This Solves
Fixes: SQLite databases, ELF/PE executables, and other binary attachments with a known signature are inlined into the model prompt as ~60k characters of garbage text when a user sends them as a document.
User Impact
User impact: binary attachments now show the usual
[Unsupported document format ...]marker instead of decoded bytes, so turns that carry them no longer trigger provider refusals; the file stays available to tools through the[media attached: ...]note. BOM-less UTF-16 text and Windows-1252 text are still read as text.Why This Change Was Made
The shared classifier now keeps a binary type identified by magic bytes binary, and only accepts a BOM-less UTF-16 guess when the bytes decode as clean text.
Technical detail
In
classifyAttachmentBytes, the binary fall-through ranresolveUtf16Charset(a NUL-ratio guess, no decode check) and thensniffTextCharset. A SQLite page with many NULs becameutf-16betext; a schema-heavy page reached the Windows-1252 sniff.detectMime({ buffer })) reports the same MIME, the result isbinarywith no text inference. MIME hints such as a declaredapplication/x-shstill go through text inference..mo) stays binary.Evidence
Regression tests (
attachment-classify.test.ts,file-context.test.ts): NUL-heavy SQLite, schema-heavy SQLite, ELF, NUL-heavy unknown bytes, and the inbound document context for SQLite and ELF; negatives for BOM-less UTF-16LE/BE, Windows-1252, UTF-8/CSV, and declaredapplication/octet-stream.Fail before, on unchanged
main(source change reverted):Pass after:
Real SQLite file (python3
sqlite3, 5000 rows, declaredapplication/octet-stream) through the realclassifyAttachmentBytesandrenderInboundDocumentContext, no credentials or model calls.Before (
main):After (this PR):
Checks:
pnpm exec oxlintandpnpm exec oxfmt --checkon the 3 touched files clean,git diff --checkclean,pnpm tsgo:coreexit 0.Gaps: no live channel or Gateway/model run (no credentials); the transcripts above exercise the production classifier and document-context renderer directly.
pnpm tsgo:core:test, full lint, and the full suite were not run.