Skip to content

Serve redaction over HTTP - #6

Open
XploY04 wants to merge 3 commits into
RemoteStar-AI:mainfrom
XploY04:feat/http-server
Open

XploY04 wants to merge 3 commits into
RemoteStar-AI:mainfrom
XploY04:feat/http-server

Conversation

@XploY04

@XploY04 XploY04 commented Nov 10, 2026

Copy link
Copy Markdown

What changed

Adds an HTTP server and Dockerfile so rsredact can run as a cluster service, the way rsparse does. The Rumero backend calls it when a company views a candidate's CV or a CV is attached to an email.

  • POST /v1/redact: multipart file (PDF, up to 25 MiB) and optional known JSON (emails, phones, urls): the candidate's own contact values, matched exactly, including LinkedIn/GitHub slug pieces that wrap onto a second line.
  • Text mode with the OpenAI provider and the box style. Pages with images, form fields or FreeText annotations also get vision detection. Every returned page is checked to have no text layer and no link annotations, or the request fails with 422.
  • Response headers: X-Rsredact-Duration-Ms, -Model-Ms, -Llm-Calls, -Detections, -Version.
  • JSON errors 400/401/413/422/429/500, GET /healthz, optional bearer token (RSREDACT_API_TOKEN), capped concurrency and queue (RSREDACT_MAX_CONCURRENCY), per-request deadline, work aborted when the client disconnects.
  • Logs never contain document text or contact values.
  • Dockerfile: Node 22, non-root, read-only friendly, with fonts-liberation (without fonts, boxes drifted and left characters readable).

Second commit fixes an independent review: images and form fields with contact details, the slug wrap after the hyphen, monospace box drift, rotated text, over-redaction of hyperlinked employers/certifications and of B.Tech/ASP.NET/@RestController, validation of known, model text in logs and headers, disconnect handling, timeouts and memory while queued.

Checks

  • npm test: 47 pass, 1 skipped (the live OpenAI test, no key in CI).
  • docker build and a read-only, non-root container run.
  • Real OpenAI timing is not measured yet; the backend logs it per redaction once deployed.

Adds src/server: POST /v1/redact takes a PDF and the candidate's known
contact values, redacts in text mode with OpenAI, checks the output has
no text or links, and returns the PDF with timing, detection and version
headers. Known LinkedIn and GitHub URLs also match the dash-joined tails
of their slug, so a profile URL that wrapped onto a second line no longer
leaves half of it readable. Concurrency and queue length are capped, and
a token can be required.

The Dockerfile installs fonts-liberation: with no fonts, every measured
character width is zero, boxes drift by a character, and the first
letter of an email stays visible.

Signed-off-by: XploY04 <2004agarwalyash@gmail.com>
Leaks:
- Pages with images, form fields or annotations get a vision pass for
  the text targets (opaqueContent: 'vision'). Findings cover the whole
  field or annotation, or the image under the model's rectangle grown
  by one cell. No vision support for such a page is a 422.
- Known LinkedIn/GitHub URLs also match a slug tail wrapped after the
  dash, at the start of a line, and one-word slugs with a digit,
  underscore or 8+ characters. The whole slug only matches after "/"
  or with a digit, so hyphenated names stay readable.
- Word boxes use pdf.js's resolved font class instead of its internal
  font id. Monospace runs are split evenly, and serif and sans are
  measured with Liberation by name, which fixes the first letter of a
  Courier email showing.
- Rotated text is boxed along its rotation.

Over-redaction:
- redact-identifying hides link text only for mailto:, tel:, social
  profiles (not repositories or LinkedIn company pages), and custom
  targets, instead of every URL.
- URL patterns skip ASP.NET, Socket.IO, B.Tech and similar; the handle
  target skips annotations, decorators and npm scopes.
- Known values that cannot be what they claim are dropped.

Server:
- Model replies are constrained to the requested target ids, and failed
  model calls are logged by name and status only.
- A request deadline, a per-call model timeout with no SDK retries,
  and an abort when the client hangs up, logged as 499.
- A slot is reserved on arrival and the body is read only once the
  request has one, so a full queue holds no bodies in memory.
- Base image pinned by digest, plus a HEALTHCHECK.

Signed-off-by: XploY04 <2004agarwalyash@gmail.com>
The service left the name readable on purpose. Clients must not see it
before an introduction is accepted, so it is now a target: the model
looks for the name, and a new known.names field gives exact patterns for
the name the caller holds. The full name matches in any case and either
order; a word of four or more letters also matches on its own when
written as a name, so a candidate called Dev or Mark does not blank
ordinary text.

Signed-off-by: XploY04 <2004agarwalyash@gmail.com>
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