Repository navigation
fix(nc-ocr-flow): correctness fixes across the Vision engine and job pipeline - #64
Merged
Merged
Conversation
…ms, batch timeout - google_engine/tesseract_engine: populate vlm_pages so the billable page counter (pages_month) and cost display stop reporting 0 for every job. - google_engine: replace the 20 MB inline-content guard (a leftover from a removed inline design; the only path is GCS upload) with a 200 MB ceiling, so legitimate scanned PDFs above 20 MB no longer hard-fail. - google_engine: _page_dims no longer silently returns (0,0) — it falls back to the local source PDF's page rect and otherwise raises, instead of dropping every Word and turning the job into status=error. - google_engine: async-batch LRO timeout default 300s -> 1800s, with elapsed time and operation name in the TimeoutError. - workflow-ocr/default.nix: expose NC_OCR_GOOGLE_LOCATION and NC_OCR_GOOGLE_BATCH_TIMEOUT.
…yer, enqueue race) - _webdav_delete: raise_for_status now runs inside the retry closure, like download/upload, so a 5xx on the final attempt is actually retried. - tesseract: assert the produced PDF really carries a text layer before stamping done — an empty layer used to overwrite the user's original. - cost_usd: subtract the 1000-page monthly free tier. - quota: pick the dimensionsInfos entry matching NC_OCR_GOOGLE_LOCATION instead of dims[0], falling back to 1800 with a warning. - /webhook: malformed JSON now returns 400 instead of 500 (NC retry-storm). - image branch: check for an existing target PDF before the paid Vision call. - /stats: state the contract explicitly — errors (unique paths), gone (file vanished from NC), errors_attempts (from the jobs table). A 404 on a queued path is recorded as 'gone' rather than a permanent 'error'. - _enqueue: per-path lock closes the duplicate-enqueue race. - PROPFIND parsing: accept any namespace prefix instead of literal <d:href>. - _PROCESSED_TTL: tunable via NC_OCR_PROCESSED_TTL setting/env.
Likivik
added a commit
that referenced
this pull request
Nov 12, 2026
* deploy(poweredge): bump ocrflow to ebaf690 (engine policy, scoped status API, claim guard) * deploy(poweredge): ocrflow 5559437 — one engine option, readable Google key * deploy(poweredge): ocrflow 1fba10e — seeding unit names the real nextcloud user * deploy(poweredge): ocrflow 937db35 — Google batch project id * poweredge(ocr): point google-ocr at the ocr-project-tmp bucket, not a bucket it may create * poweredge(ocr): worker moves bytes over the app API, not WebDAV * deploy(poweredge): ocrflow api-transport fixes (byte fetch + enqueue id) * deploy(poweredge): ocrflow pages/chars reporting * feat(nc-rag): enable cross-encoder reranking in nextcloud-mcp SEARCH_RERANK_URL points at serenity's llama-reranker (:8082/v1/rerank) via the direct Cohere-protocol path, so no gateway M2M token is needed. Also opens 8082 on tailscale0 explicitly instead of relying on the port happening to be reachable. * fix(nc-rag): rerank top-50 with a 120s timeout The upstream 30s default times out when 200 chunks of up to 2000 chars are scored on the 1660, and nc-mcp degrades silently to retrieval order — so reranking was on paper only. Measured ~0.09s/doc; 50 candidates keeps latency ~8s and 120s absorbs a cold GPU. * deploy(poweredge): four OCR failure-class fixes * deploy(poweredge): real failure sites (#57) * deploy(poweredge): pdfio, reason codes, empty-source skip, readiness, retry * deploy(poweredge): reason codes, stage events, 422 classification (#64-#69) * feat(hermes): bump to v0.23.1 with a local patchelf gate v0.23.1's nix/pm-packages.nix backports NixOS/patchelf#672 onto patchelf unconditionally. That patch is written for 0.19 and rejects 4/6 hunks against the 0.15.2 that nixpkgs reverted to (61a15beb37, 2026-10-30, tracking #577387), so nothing built. - apply upstream PR NousResearch/hermes-agent#152542 (gates the backport to 0.19.0-0.19.2) over the flake source and callPackage from it - use hermes-agent's OWN uv2nix/pyproject stack: its python.nix passes default-groups, which our older uv2nix rejects - pin nix/pnpm-deps-hash to the store hash fetchPnpmDeps produces on our nixpkgs; upstream's was made with 02c087f Drop both patches once a released tag carries the gate and we bump nixpkgs. * test(smoke): read the expected hermes version from /etc The probe hardcoded *v0.21.7*, so the 0.23.1 build reported HERMES_VERSION_BAD and the gate failed on a stale literal rather than on the system. The aspect now writes /etc/hermes-expected-version from the same hermesVersion that builds the package; the probe compares against it and keeps a literal only as a loud fallback. VM smoke: PASS (28 running / 68 loaded services, both ZFS pool imports allowlisted as guest-impossible). --------- Co-authored-by: Likivik <[email protected]>
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.
Why
A static review of the OCR path (plus one live production symptom) turned up a batch of confirmed defects. The only user-visible one so far was
pages_monthstuck at 0 with 98 jobs, but several are latent hard failures.Engine (Google Vision)
vlm_pageswas always empty →pages_month/cost display reported 0 for every job whilejobs_monthgrew. Bothgoogle_engineandtesseract_enginenow populate it with real page indices."use the GCS path"although GCS upload is the only path (the comment in the same function says so). Every legitimate scanned PDF >20 MB hard-failed. Replaced with a 200 MB ceiling._page_dimsreturned(0, 0)when Vision omittedpages[]; the normalized-vertex branch then dropped every Word → zero blocks →status=error. Now falls back to the local source PDF's page rect, and otherwise raises loudly instead of silently zeroing.NC_OCR_GOOGLE_LOCATIONandNC_OCR_GOOGLE_BATCH_TIMEOUTare now set explicitly (location must match the bucket's region).Pipeline (webhook server)
_webdav_deletenow callsraise_for_status()inside the retry closure (download/upload already did), so a 5xx on the final attempt is retried instead of leaving both the source image and the new PDF in Nextcloud.cost_usdsubtracts the 1000-page free tier.dimensionsInfosentry for the configured region instead ofdims[0](which could be another region's limit), with a conservative 1800 fallback + warning./webhookreturns 400 on malformed JSON instead of 500 (no more Nextcloud retry-storm)./statsnow states its contract:errors(unique paths),gone(file vanished from NC),errors_attempts(from the jobs table). Production showederrors: 36vs 0 error rows injobs— all 36 were stale rows for deleted test probes. A 404 on a queued path is now recorded asgone, not a permanenterror._enqueuetakes a per-path lock, closing the duplicate-enqueue race (in-process; a multi-process deployment still wants a jobstore-level transaction).<d:href>._PROCESSED_TTLis tunable via theNC_OCR_PROCESSED_TTLsetting/env.Not fixed here
Bounded automatic retry of transient
status='error'jobs — deferred, it needs a sweeper design rather than a patch.Tests
cd pkgs/nc-ocr-flow && uv sync --group dev && .venv/bin/python -m pytest tests/ -q→ 196 passed, 1 failed. The failure istest_orientation.py::TestDetectOrientation::test_takes_pp_lcnet_when_confident(local PP-LCNet model unavailable; same failure on unmodifiedmain, unrelated to these files).