Repository navigation
fix(nc-ocr-flow): combine A1-A3 + B1-B6 audit fixes on top of #65/#66/#68 - #69
Merged
Merged
Conversation
A1 _strip_existing_text now has an optional page_idx parameter; callers passing one strip only that page, callers passing None (or omitting it) keep the old whole-doc behaviour. _finalize uses the per-page form so a page whose engine returned no blocks retains its pre-existing text layer. A2 google_engine._aggregate_json_results returns list[tuple[int, OcrResult]] with REAL 0-indexed source page indices and warns on duplicate pageNumber; vlm_pages is no longer list(range(n)). A3 google_engine._page_dims local-PDF fallback renders at the new _PAGE_DIMS_FALLBACK_DPI = 200 and returns PIXELS, not PDF points.
…obstore/orientation fixes
A1 per-page text strip in _finalize: pages whose engine result has no
blocks keep their pre-existing text layer; _strip_existing_text gained
an optional page_idx=None parameter (None = old whole-doc behaviour).
A2 google_engine._aggregate_json_results returns
list[tuple[int, OcrResult]] with REAL 0-indexed source page indices
and warns on duplicate pageNumber, so vlm_pages is no longer
list(range(n)).
A3 google_engine._page_dims local-PDF fallback now renders at a new
_PAGE_DIMS_FALLBACK_DPI = 200 and returns PIXELS, not PDF points.
B1 force=True no longer bypasses the per-path in-flight gate in _enqueue.
Two concurrent force callers collapse to ONE jobs row, returning
status 'already_running' naming the existing job.
Added jobstore.in_flight_job_for_path.
B2 retry counters no longer double-count and /stats now spreads
retries_total + retries_queued into the payload the NC app reads.
B3 _webdav_exists treats HTTP 410 Gone like 404.
B4 jobstore._prune skips rows waiting on a backoff
(COALESCE(next_run_at,0) <= now).
B5 _ENQUEUE_LOCKS got a bounded 1h idle TTL sweep.
B6 the expensive orientation precheck was REMOVED:
preorient_pages_safe calls preorient_pdf exactly once;
_detect_all_pages_orientations does not exist;
a regression-guard test asserts its absence.
Conflicts resolved:
- jobstore.py:6 conflicts around the C6 retry migration and the
stats() retry counters. Kept main's _migrate_add_retry_columns
helper (PR #68 ordering fix) and main's typed-docstring style for
attempts_i/next_run_at_f. Reconciled the schema column defs and
the inline ALTER loop into one migration path with the index
AFTER the ALTERs (PR #68 invariant).
- webhook_server.py:2 conflicts. Adopted main's _webdav_exists
structure (with timeout parameter) and B3's 410-as-gone behaviour
(now uses requests.request("HEAD", ...) so the standard test
monkeypatching ws.requests.request intercepts the call). Adopted
main's jobstore.stats() call site in /stats and added the B2
retries_total/retries_queued spread from the same js handle.
- test_webhook_api.py:1 conflict. Both sides added disjoint test
blocks (main's C1-C6 and B's B1-B6); kept both, stripped the
conflict markers.
- orientation.py: removed the precheck call and the
_detect_all_pages_orientations function (B6). Main's docstring
already described the regression; preserved the audit contract.
Kept the A-side 0.3.0 -> 0.4.0 uv.lock version bump (package version
was already bumped in A; no further change).
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.
Summary
Rebase and combine the two audit change sets onto current main, with conflicts resolved and tests green.
A1-A3 (engine/text fixes)
_strip_existing_textgains an optionalpage_idxparameter;_finalizenow strips only the pages it is about to overwrite, so a page whose engine returned no blocks keeps its pre-existing text layer.google_engine._aggregate_json_resultsreturnslist[tuple[int, OcrResult]]with REAL 0-indexed source page indices and warns on duplicatepageNumber.vlm_pagesis no longerlist(range(n)).google_engine._page_dimslocal-PDF fallback renders at the new_PAGE_DIMS_FALLBACK_DPI = 200and returns PIXELS, not PDF points.B1-B6 (webhook/jobstore/orientation fixes)
force=Trueno longer bypasses the per-path in-flight gate in_enqueue. Two concurrent force callers collapse to ONE jobs row, returningstatus='already_running'naming the existing job. Addedjobstore.in_flight_job_for_path./statsnow spreadsretries_total+retries_queuedinto the payload the NC app reads._webdav_existstreats HTTP410 Gonelike404. Switched the call torequests.request("HEAD", ...)so the standard test pattern of patchingws.requests.requestactually intercepts it (requests.headcapturesrequestat import time and bypasses attribute lookup on the parent module).jobstore._pruneskips rows waiting on a backoff (COALESCE(next_run_at,0) <= now)._ENQUEUE_LOCKSgot a bounded 1h idle TTL sweep via_ENQUEUE_LOCK_TTL_S = 3600.0and_ENQUEUE_LOCKS_LAST_USED.preorient_pages_safecallspreorient_pdfexactly once;_detect_all_pages_orientationsdoes not exist;tests/test_orientation.py::TestNoExpensivePrecheckasserts its absence.Conflicts resolved
jobstore.py(6 conflicts) — both sides addedattempts/next_run_atcolumns and a retry-countingstats(). Kept main's_migrate_add_retry_columnshelper (the PR fix(nc-ocr-flow): create the retry index after the ALTERs (jobstore init was dead on existing DBs) #68 ordering fix that puts the index AFTER the ALTERs and never in the schema script) and main'sattempts_i/next_run_at_ftyped normalization. Reconciled the schema column defs (INTEGER DEFAULT 0/REAL DEFAULT 0) and dropped B's inline ALTER loop + redundantCREATE INDEX idx_jobs_pending(the ordering bug PR fix(nc-ocr-flow): create the retry index after the ALTERs (jobstore init was dead on existing DBs) #68 fixed). Adopted main's two-COUNT implementation of the retry counters; tests pass with bothretries_totalandretries_queuedexposed.webhook_server.py(2 conflicts) — adopted main's_webdav_existsstructure (withtimeoutparameter) and B3's410-as-gone behaviour. Adopted main'sjobstore.stats()call site in/statsand added the B2retries_total/retries_queuedspread from the samejshandle.test_webhook_api.py(1 conflict) — both sides added disjoint test blocks (main's C1-C6 + B's B1-B6). Kept both and stripped the conflict markers.orientation.py— removed the precheck call and the_detect_all_pages_orientationsfunction (B6). Main's docstring already described the regression; preserved the audit contract._maybe_schedule_retry(job)1-arg variant B introduced (it shadowed main's 3-arg signature that the tests depend on) and removed the now-redundantfinally-block call (main's exception handlers already schedule retries for every transient failure).Tests
test_takes_pp_lcnet_when_confidentthat needs the ONNX PP-LCNet model file absent in this environment; passes in CI).Notes
0.3.0 → 0.4.0inuv.lock; preserved.uv.lockis unchanged from main (only test-runner-only packages installed locally are not part of the project's lockfile).