Skip to content

Binary files overpromise at every layer — a stored .doc previews as 'usable as context', lists as textReadable, then read fails with encoding advice #162

Closed

Description

@bencode

Problem

Import rejects nothing by format (core/files.ts ImportRejectionReason is size/path/storage only), so a legacy report.doc or ledger.xls lands in the library — and then every layer states something untrue about it:

  • Its tab reads "This file is stored locally and can be used as context in a later iteration." (features/reader/file-preview.tsx:78–86). No tool can read that file, and the sentence points at no path that would.
  • The agent's own inventory misstates it: getReadability (features/assistant/create-reader-agent.ts:33–36) marks anything under 5 MiB that isn't a converted kind as textReadable: true, so list presents the Word binary as readable text.
  • read then fails through openTextSource with "This file is not UTF-8 text. If it is text in another encoding, import a UTF-8 copy." (features/assistant/text-source.ts:19–21) — for a .doc, neither half applies: it is not text, and a UTF-8 copy is not a thing its reader could make.
  • @-mentioning the file sends recommendedTool: 'read' (core/reader-message.ts:22), steering the agent straight into that failure.

The reader is told the file will be useful, the assistant is told it is readable, and the error advises a repair that does not exist. The product reads .docx/.xlsx fully — the real repair (save as .docx/.xlsx) is never named.

Proposal

  • Make getReadability honest about binary kinds: a file whose previewKind is unsupported reports textReadable: false with a reason naming the state, instead of the size-only rule.
  • Match the read failure to the file: known legacy Office extensions (.doc, .xls) get "save it as .docx/.xlsx to read it here"; other binaries get "stored, but no reader for this format" — never encoding advice. (Read plain text in the encodings readers actually have — GBK .txt meets 'Preview unavailable', and the assistant answers 'import a UTF-8 copy' #160 covers files that genuinely are text in another encoding; this is the binary branch of the same seam.)
  • Align the preview tab with the same truth: for .doc/.xls, name the conversion step; drop the "can be used as context" promise for files no tool can read.

Goal

After this, list reports a stored .doc as not text-readable with a reason, read's error names the conversion repair, and the preview tab states the same fact — one file, one story at every layer.

Verification

# the legacy-Office classification must exist before the tests can see it;
# fails today, passes once .doc/.xls get an honest refusal at the seam
grep -rqiE "'doc'|'xls'|msword|legacy office" ui-packages/web/src/core/files.ts ui-packages/web/src/features/assistant/document-access.ts
# a stored .doc fixture: list reports textReadable:false with a reason,
# and read fails with the convert-to-docx advice, not the UTF-8 advice
cd ui-packages/web && pnpm vitest run --project unit src/features/assistant/create-reader-agent.test.ts src/features/assistant/local-tools.test.ts

Refs

Activity

  1. added
    enhancement
    source:scheduled
    on Oct 21, 2026
  2. bencode commented on Oct 21, 2026

    @bencode
    OwnerAuthor

    Independent review — posted by the scheduled issue-reviewer loop, independent of the authoring session.

    Evidence audit (main @ ebb0ee0): all citations hold.

    • Preview copy verbatim — "stored locally and can be used as context" for previewKind === 'unsupported' && !textReader (features/reader/file-preview.tsx:78–86).
    • Size-only readability rule — anything ≤ 5 MiB that isn't a converted kind ⇒ textReadable: true (features/assistant/create-reader-agent.ts:33–36).
    • UTF-8 error verbatim (features/assistant/text-source.ts:19–21); recommendedTool sends read for every non-image (core/reader-message.ts:22).
    • ImportRejectionReason is size/path/storage only (core/files.ts:32–37); previewKindFor at files.ts:101 is where the format knowledge lives.

    Sensor: lint passed. verify "passed" is vacuous — the cited test files pass on main with only today's assertions (create-reader-agent.test.ts:553 asserts textReadable: true for .docx; nothing covers .doc). Code confirms not implemented.

    Sharpening suggestions:

    1. Put the legacy-Office classification (.doc/.xls ⇒ unsupported-binary) in core/files.ts beside previewKindFor — one source of truth — and let getReadability, the read error and the preview copy all read it; a shared reason string makes "one file, one story" enforceable.
    2. Name the new fixture + assertions in the Verification block (stored report.doc → list reports textReadable: false with reason; read fails with save-as-docx advice), so the verify gate distinguishes implemented from vacuous pass.
    3. Boundary with Read plain text in the encodings readers actually have — GBK .txt meets 'Preview unavailable', and the assistant answers 'import a UTF-8 copy' #160 confirmed clean: Read plain text in the encodings readers actually have — GBK .txt meets 'Preview unavailable', and the assistant answers 'import a UTF-8 copy' #160 = bytes that are text in another encoding; this issue = bytes that are not text.

    Duplicates: none in open+closed titles — #160 is the companion encoding branch, not overlap.

    Verdict: valid — stays open.

  3. bencode commented on Oct 25, 2026

    @bencode
    OwnerAuthor

    Re-audit — posted by the scheduled issue-reviewer loop, independent of the authoring session. Audited against main@90b046f.

    Evidence audit: one anchor drifted, behavior unchanged. Commit 7a022aa ("how the assistant opens a document lives in document-access.ts, apart from the agent") moved the size-only readability rule from create-reader-agent.ts:33 to features/assistant/document-access.ts:19-22 — getReadability still answers textReadable: true for any ≤ 5 MiB non-converted kind, so a stored .doc still overpromises exactly as the issue says. All other anchors hold verbatim: file-preview.tsx:79-86 ("stored locally and can be used as context"), text-source.ts:20 (UTF-8 advice), reader-message.ts:22 (recommendedTool), files.ts:101 (previewKindFor).

    Duplicate check: none — #160 is the companion encoding branch (bytes that are text), correctly separate.

    Verification block repaired (logged here per policy): verify was passing vacuously — both cited test files pass on unmodified main with today's assertions, so the gate reported nothing implemented as implemented. Prepended a discriminating grep over the two candidate seams:

    grep -rqiE "'doc'|'xls'|msword|legacy office" ui-packages/web/src/core/files.ts ui-packages/web/src/features/assistant/document-access.ts

    It fails today ✓, re-linted ✓, verify now fails today ✓ (was falsely passing). Any honest-refusal implementation must name the legacy extensions somewhere on these surfaces.

    Verdict: valid, stays open. The first review's sharpenings stand, now with the moved seam: put the legacy-Office classification in core/files.ts beside previewKindFor and let getReadability (in document-access.ts), the read error and the preview copy all read it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementsource:scheduled

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions