Repository navigation
feat(D147): convert by reference — pre-signed raw URLs for URL-capable routes - #545
Conversation
… routes The owner decided that no transport may cap uploads. A conversion route that implements UrlConverter gets a short-lived pre-signed GET URL for the raw object plus its size and MIME instead of the bytes, whenever the raw store implements the new PresignedReadPort (MinIOObjectStore.presign_get, SigV4 query signing, local) and the size is known. Every other route or store keeps the bytes path. Covers provider fetch by URL for OCR/vision routes (plan 2i) as the same capability. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F9cMsQBqiW2qU2ow4zeNCm
Codex review round 1 (gpt-6.1-sol, max effort)VERDICT: APPROVE No blocker or major findings.
The ingest conclusion is otherwise sound: neither supported ingestor can register an existing raw object without bytes. However, document_catalog.py:77 already provides metadata-only registration through The implementation checks out: limits and representation replay precede signing; URL usage is metered before envelope validation; error mapping is preserved; bytes fallback and lane checkpoints retain their behavior. Presigning uses the bound bucket, validated key, and SigV4 GET signing. Rule 4 identities and component versions remain unchanged. Validation: 102 passed, 1 expected failure. An additional URL-route run passed 17 reuse tests, with 33 conversions and zero worker raw reads; the existing Claimify expected failure remained. The dedicated PostgreSQL container was removed. Worktree unchanged. Disposition (Claude)The minor is accepted. The staged-ingest proposal in the PR body now keeps today's full validation: content-based MIME detection that reads a PDF's body and EOF and an Office file's ZIP metadata, plus D74 admission and managed-text metering. It names |
This adds a generic seam so the convert stage can hand a converter a reference instead of the bytes. It follows the owner's decision of 2026-11-07: no transport-driven upload caps. It also covers plan item 2i (OCR/vision providers fetch inputs by URL).
API
UrlConverter, the raw store is aPresignedReadPort, and the version'sbyte_sizeis known. The worker then signs the raw object's URL and callsconvert_from_url; it never reads the bytes.LocalFSObjectStorecan't presign.result.usage_eventsand error mapping all stay the same. Lane checkpoints don't apply to a URL route.convert_from_urland pass the URL to its provider, for example Mistral'sdocument_url. No engine route changes in this PR.presign_get(bucket, key, ttl). Object stores here are bound to one bucket each, so the bucket is the store's, and the method takes the key and TTL only.Ingest of an object already in the raw bucket
Nothing exists today. Ingest (
UploadIngestor.ingestandingest_observed) needs the bytes. It derives the content hash, which is lineage identity under D55, and the content-addressed raw key{doc_id}/{sha256}/original{ext}from them. It also needs them for byte-based MIME detection and managed-text metering.Proposed smallest seam, not built:
UploadIngestor.ingest_staged(deployment_id, staged_key, filename, mime, …).DocumentCatalog.record_uploadis the building block for recording the version.ingestdoes, then deletes the staged object.This needs two ObjectStore additions: a streaming read and
copy.Tests
test_two_deployment_contexts_pg.py: B's route is now a URL route over a presigning raw store. B converts by URL with the right size, MIME and file name, and its raw store records zero direct reads. A still converts in-process from bytes.test_minio_store.py: a real boto3 client signs a GET URL locally forfs-raw/doc/hash/original.pdfwithX-Amz-Expires=900. A non-positive TTL is refused.Checks
ruff, pyright (0), import-linter, unit lane (3121 passed)
e0/convert DB tests and the two-database test on PG 19 RC 1
CI (green)
Codex review: APPROVE (round 1; one PR-body minor fixed)
I have read and agree to the RememberStack Contributor License Agreement v1.0.
🤖 Generated with Claude Code
https://claude.ai/code/session_01F9cMsQBqiW2qU2ow4zeNCm