fix: serve original PDF uploads (passthrough) and persist artifacts on disk#107
Open
seonghobae wants to merge 3 commits into
Open
fix: serve original PDF uploads (passthrough) and persist artifacts on disk#107seonghobae wants to merge 3 commits into
seonghobae wants to merge 3 commits into
Conversation
Serve uploaded PDFs passthrough instead of the placeholder artifact: DefaultDocumentConversionService now seeds the artifact store with the original upload bytes when the source declares PDF (extension or content type) and carries the %PDF- magic header, and DefaultConversionWorker completes the job without generating a placeholder when seeded bytes exist. Non-PDF sources keep the placeholder path; real docx/hwp conversion remains future work and is documented as such. Add FileSystemArtifactStore, a disk-backed ArtifactStore that persists artifact bytes plus a minimal metadata sidecar (docId, size, sha256, storedAt) under clearfolio.artifact-store.root-dir (default data/artifacts) so artifacts survive restarts, with an in-memory cache on the read path. ArtifactStoreConfig selects filesystem (default) or in-memory mode via clearfolio.artifact-store.mode; InMemoryArtifactStore remains for tests and the in-memory mode. HMAC artifact-token gating and HTTP Range serving are unchanged. Tests: PDF passthrough serves original bytes (magic-byte verified), non-PDF still gets the placeholder, disk store round-trips and survives re-instantiation, metadata sidecar contents, IO failure paths, store mode selection, plus coverage for previously unexercised constructor and state-store branches (JaCoCo line/branch miss = 0). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RjGVapDZ3k7V7zKYk16P4C
OWNER MUST CONFIRM: the demo UI footer asserts HYOSUNG copyright (ViewerUiController); if HYOSUNG holds rights, replace this LICENSE choice accordingly. Merging is the owner's license decision. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RjGVapDZ3k7V7zKYk16P4C
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RjGVapDZ3k7V7zKYk16P4C
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What / Why
Clearfolio's conversion pipeline was a stub:
DefaultConversionWorkeralways calledPdfBoxArtifactGenerator.generatePdf(job), so every upload — including PDFs — was served as a one-page placeholder containing only the filename and hash, andInMemoryArtifactStorelost every artifact on restart. This PR makes uploaded PDFs actually viewable and makes artifacts survive restarts, which unblocks real sheet-music viewing for the BandScope integration.1. PDF passthrough (originals are served, not placeholders)
DefaultDocumentConversionServicenow detects PDF sources (extension or content type, confirmed by the%PDF-magic header) and seeds the artifact store with the original upload bytes at submit time.DefaultConversionWorker.performDefaultConversionserves seeded bytes as the artifact and only generates the placeholder when nothing was seeded.ARCHITECTURE.mdand the worker Javadoc. No conversion is faked.2. Disk-backed artifact store (survives restarts)
FileSystemArtifactStorepersists artifact bytes plus a minimal metadata sidecar (docId,sizeBytes,sha256,storedAt) under a configurable root:InMemoryArtifactStoreis kept for tests andmode: in-memory;ArtifactStoreConfigselects the implementation.ArtifactControllerTest/ArtifactLinkServiceTestcases pass untouched).3. LICENSE
The repo had no LICENSE while
docs/security/2026-07-02-license-policy.jsonitself blocks unlicensed components. This adds an Apache-2.0LICENSEwith copyright holder "ContextualWisdomLab" (separate commit so it can be dropped independently). The HYOSUNG footer text was deliberately not modified.Tests
DefaultConversionWorkerTest,DefaultDocumentConversionServiceTest).pdfwithout%PDF-magic and non-PDF uploads still get the placeholder pathFileSystemArtifactStoreTest)ArtifactStoreConfigTest,ArtifactStorePropertiesTest)Gates (all green locally)
mvn -q -DskipTests compile(warning/deprecated budget 0,-Werror)mvn -q verify/mvn testcom.clearfolio.viewer.*: 0 missed lines / 0 missed branchesmvn -q -DskipTests javadoc:javadoc: no warningsmarkdownlinton changed docspython3 scripts/check_sbom_license_policy.py …: 0 violations (engineering-review mode)SUCCEEDED→ artifact bytes byte-identical to upload; missing token → 401;Range: bytes=0-4→ 206/5 bytes;data/artifacts/<jobId>.pdf+.meta.propertieswritten to disk; docx upload → placeholder PDFBandScope integration note
BandScope currently integrates via viewer-contract +
pdfjs-diston its own; once this lands it can swap to clearfolio's/api/v1/convert/jobs+ signed/artifacts/{docId}.pdfendpoints for real sheet-music viewing.🤖 Generated with Claude Code
https://claude.ai/code/session_01RjGVapDZ3k7V7zKYk16P4C