Skip to content

knowledge.formats lists the formats an ingest reads and whether an extractor serves each - #282

Merged
zlareb1 merged 8 commits into
mainfrom
feat/knowledge-formats
Nov 6, 2026
Merged

zlareb1 merged 8 commits into
mainfrom
feat/knowledge-formats

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Related: #157

Changelog category (leave one):

  • New Feature

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

knowledge.formats lists every document format an ingest reads, the file extensions and media types that select each, and whether a configured extractor serves it, with the upload's size limit and the extensions it refuses, so a client can tell a person before sending a file that it would not be read.

Why

The issue asks that "capability advertisement comes from what the configured extractors declare", and its plan has the dashboard's Library show capability badges for a file before it is sent. Nothing on the wire said which formats a deployment reads. server.knowledge.app.extractors.available_formats computed it, but no op served it and it had no caller. A client could only upload a file, ingest it, and wait for format_unavailable. This is the server half; the dashboard uses it in the next PR.

Design

  • knowledge.formats (viewer, read-only, experimental): for each of KNOWN_FORMATS, sorted, it returns:

    • format;
    • extensions and media_types, the names format_of maps to it (new pure helper document_formats.names_of);
    • available: true when a service a file of it can go to declares it (its own route, else the default service and the routes of the media types that name it), false when every such service was read and none does (an ingest fails format_unavailable), and null while one could not be read (an ingest then waits for the service and retries). A client tells "will not be read" from "unknown, try again shortly". A format served only by a media type's route is read when the upload carries that media type, which the dashboard and the SDKs send when the file's type is known.

    The output also carries max_upload_bytes (LOOM_KNOWLEDGE_UPLOAD_MAX_BYTES), refused_extensions (doc, ppt, xls, which the upload refuses by name) and default_format: document_formats.DEFAULT_FORMAT (text), the constant format_of itself now falls back to, for a name and media type that select nothing.

  • Bounded read:

    • available_formats (now built on format_availability, which returns each format's URL, '' for none, or None for unknown) used to read each service with the extract timeout (LOOM_DOCUMENT_EXTRACTOR_TIMEOUT_S, 180 s by default), one after another on a cold cache. An unreachable extractor would have held the listing for minutes.
    • It now reads every service a format can go to together, each within CAPABILITIES_READ_S (5 s; the same bound the tune report's read used, now one constant in extractors.py). A service not read in time declares nothing, and its failure is remembered for the capabilities cache's minute (_unreadable), so a down or blackholed service costs one wait a minute, not one per listing. A successful capabilities read (by an ingest, say) clears the mark, and a fresh cached read wins over a mark a slower listing read left after it, so the listing does not say no while an ingest reads the format. Concurrent cold listings still each read once.
    • Each service's capabilities stay cached a minute, as before, so a warm listing reads nothing.
    • The bounded read is one helper (_formats_within), which the extractor report (configured_services) now shares; its log line names a timeout as timed out (before, a bare TimeoutError logged nothing after the URL), which a test asserts.
    • The routing rule is unchanged: a format's own route hides the default service and its media types' routes.
  • Latency budget: 5,500 ms in OP_BUDGETS_P99_MS, the cold-read bound plus headroom.

  • Where it lives: beside the ingest ops in the knowledge plane. ops.capabilities (insights) would have imported the knowledge plane's extractor client across planes, and it describes operations, not data.

  • Docs: a row in the knowledge page's op table, a paragraph in "Ingesting files", and a sentence in the extraction architecture page's routing section.

  • Generated files: the SDK op tables (Python and TypeScript) and the reference pages are regenerated.

Alternatives considered:

  • Returning the capabilities each service declares as they are (per-format limits and options). That exposes the configured service URLs' structure, which are secrets, and more than a client needs to decide whether a file will be read.
  • Computing availability in each client from knowledge.ingest_status failures. That costs an upload and an ingest per answer.

Scope and risk

  • Read path only: no table, migration, worker or setting change beyond the op's budget entry.
  • What the answer reveals: formats, not service URLs or errors; a service that cannot be read is logged as before.
  • Trust: available is what the extractor declares; whether a given file extracts is still decided at ingest.

Compatibility, rollout and rollback

  • Rolling upgrade: a build N-1 replica answers knowledge.formats with 404; a client treats that as availability unknown (the dashboard PR does).
  • Wire: one new op; no field changes elsewhere.
  • Operator steps: none.
  • Rollback: reverting removes the op.

Tests

  • Unit, tests/unit/test_knowledge_formats.py: against the reference extractor in process and stub services:
    • each format's names, sorted;
    • a format whose own route declares it is available, one whose route is read and does not declare it is not, and one whose route is unreachable is unknown (null), though the default service declares it;
    • the upload limits and the refused extensions;
    • with no extractor configured, every format is false;
    • a service that never answers costs available_formats its bound and declares nothing (its formats unknown), and a second listing within the minute does not read it again, while one past the minute does, one read since by an ingest counts again, and a fresh cached read wins over a mark left after it;
    • default_format is what format_of falls back to.
  • Unit, existing: tests/unit/test_knowledge_extractors.py passes, its fixture clearing the new failure cache with the capabilities cache (the listing tests: an unreachable service read once, a format routed only by media type, a media type route key).
  • Unit, updated: the SDK public-API snapshot.
  • Integration, tests/integration/test_knowledge_formats_live.py: against a server, its ClickHouse and the reference extractor, the formats, names and limits come back, and the available set equals the server's own available_formats() (all 11 of the reference extractor's here); with no configured extractor declaring anything the test skips, so an empty comparison cannot pass.
  • Full unit suite: run on the rebased head before the merge.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. Checked: the op against a real server and extractor, the bound with a service that never answers, and a review at every push.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/reference/ tables (python scripts/codegen/docs_reference.py), the reach manifest, schemas/schema.sql (make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

zlareb1 and others added 8 commits November 6, 2026 04:33
…tractor serves each

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…t format is routing's own

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…port; its timeout is logged

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ut's log line is tested

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ngest ops stay together

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ad, and that an ingest then waits

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 merged commit 8efee3b into main Nov 6, 2026
23 of 24 checks passed
@zlareb1
zlareb1 deleted the feat/knowledge-formats branch November 6, 2026 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant