seanpedrick-case/doc_redaction/doc-redaction-modifications

Claude Code and agent skill by seanpedrick-case/doc_redaction

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Review and reapply: two-pass workflow — Pass 1 (OCR/CSV/text, default) then optional Pass 2 (VLM per page). Edit *_review_file.csv, preview, /review_apply, verify. Parallel page orchestration → doc-redact-page-review. Initial redaction → doc-redaction-app.

Install

npx vskill@latest install seanpedrick-case/doc_redaction/doc-redaction-modifications

SKILL.md

Goal

Repeatable review → edit CSV → preview → `/review_apply` → download → verify when you already have the original PDF and a matching *_review_file.csv.

Initial redaction only: `../doc-redaction-app/SKILL.md`.

Parallel page-range review (subagents): `../doc-redact-page-review/SKILL.md` — one child per page for Pass 1, parent merges and applies once; Pass 2 (optional VLM) runs after Pass 1 outputs exist.

Two-pass review model

Review is split into a fast, text-based first pass (default) and an optional visual second pass. Do not run VLM on every page unless the user explicitly requests Pass 2 or you are re-checking specific flagged pages.

Pass 1 — OCR / CSV / text (default)Pass 2 — Visual VLM (optional)
Inputs*_review_file.csv, *_ocr_output_* (line), *_ocr_results_with_words_* (word), original PDFPass 1 outputs: merged CSV, *_redacted.pdf, preview/redaction overlay PNGs
MethodsRow edits, word/line OCR alignment, regex/policy rules, overlap checks, PyMuPDF text extraction, local preview_redaction_boxesOpenAI-compatible VLM (/v1/chat/completions + page PNG)
Cost / timeLow — no image tokensHigh — ~1–2 min/page on local VLMs; scales with page count
WhenAlways — completes the first reviewed applyUser asks for visual QA; high-risk pages; Pass 1 text checks inconclusive
ApplyOne /review_apply after Pass 1 mergeEdit CSV from VLM findings → one more /review_apply if changes made

Default workflow: Pass 1 only → deliver. Run Pass 2 only when needed.

Endpoint semantics (do not get this wrong)

EndpointApplies redaction?Text layer stripped?Output to use
/doc_redactProposes boxes; may emit an early *_redacted.pdfRun-dependentReview CSV + OCR — treat as draft until Pass 1 review + apply
/preview_boxesNo — draws boxes on rendered page images onlyN/ACoordinate QA only
/review_applyYes — from original PDF + `*_review_file.csv`Yes — PyMuPDF redaction + apply_redactions()*_redacted.pdf

Never implement a custom “true redaction” PyMuPDF script because text_layer_leaks appeared. Fix CSV coverage and coordinates first, then call /review_apply again. Exception: reading PyMuPDF word positions to add normalized CSV rows is allowed — writing the final PDF without /review_apply is not (see task template § Agent anti-confusion rules).

Never run post-apply text-layer checks on *_redactions_for_review.pdf — that file retains text for human review. /review_apply returns both files; only *_redacted.pdf is the deliverable.

Use `tools/verify_redaction_coverage.py` or POST /agent/verify_redaction_coverage — do not reimplement coverage logic ad hoc (pandas/regex scripts). On split-container Pi deployments, pre-apply checks use the CLI on downloaded artifacts (edited CSV is local); post-apply checks use the Agent API with server paths — see § Split-container verify below.

Text-layer leak troubleshooting

When text_layer_leaks appear on *_redacted.pdf:

  1. Confirm the PDF basename ends with _redacted.pdf (not _redactions_for_review.pdf).
  2. Pre-apply: all xmin/ymin/xmax/ymax must be normalized 0–1 (df[bbox_cols].max().max() <= 1). Never paste PyMuPDF absolute points without dividing by page width/height.
  3. Read leak_likely_causes on each page in the coverage report:
CauseMeaningFix
missing_page_boxesNo review rows on that pageAdd boxes from word/line OCR or PyMuPDF text positions (normalized)
missing_review_boxesWord OCR hits not intersecting any boxAdd/extend review rows
coord_not_normalizedCSV rows use pixel/point coords (>1)Normalize to 0–1; re-apply (headless apply now rejects invalid coords)
coord_mismatch_or_image_textWord OCR covered but text still extractableWiden boxes, split multi-line blocks, or redact image areas (CUSTOM); image-baked text cannot be stripped by text redaction alone. If `pixel_failures` is empty after apply, stop adding full-span boxes — document limitation or use Pass 2 visual check on those pages.

Word OCR can show 100% covered while the text layer still leaks — that is usually coordinates or image text, not a broken apply endpoint.

Pass 1 — OCR / CSV / text review

Use artefacts from the same redaction run. No VLM in this pass.

Inputs (discover in output folder)
FileUse
*_review_file.csvMaster list of proposed boxes — add/remove/relabel rows
*_ocr_results_with_words_*.csvWord boxes (word_x0…word_y1) for precise coordinates
*_ocr_output_*.csvLine-level OCR — reading order, line text, line indices; use for context and same-line grouping
Original (unredacted) .pdfPreview overlays; text extraction sanity checks
*_ocr_results_with_words_*.jsonOptional — same word data as CSV when easier to parse
Pass 1 loop (per page or whole document)
  1. Load *_review_file.csv (encoding="utf-8-sig").
  2. Policy edits — remove false positives, add missing PII rows, relabel (programmatically, not Excel-only).
  3. Word OCR — match page + word_text; merge words on the same line (|Δy0| < ~0.01); separate boxes across lines.
  4. Line OCR — use line CSV for phrase context, line numbers, and confirming reading order when word boxes fragment a name or address.
  5. Coverage report (mandatory before apply) — run `tools/verify_redaction_coverage.py` or `POST /agent/verify_redaction_coverage` with must_redact / must_not_redact regex lists. Fix policy flags (uncovered_terms, over_redacted, text_layer_leaks); re-run until pass_strict is true.
  6. Suspicious-row prune (standard Pass 1 cleanup) — remove short OCR-fragment boxes ("-", ".", "Ho", etc.) that do not match must_redact. CLI: --prune-suspicious --pruned-output merged_pruned.csv or API: auto_prune_suspicious: true. Re-run coverage; target pass_with_cleanup: true.
  7. Preview — preview_redaction_boxes or /preview_boxes on edited CSV (spot-check worst pages from the report).
  8. Merge full-document CSV (all pages) if reviewing a subset — see page-review skill.
  9. One /review_apply → download newest *_redacted.pdf / *_review_file.csv (sort by st_mtime).
  10. Coverage report (after apply) — re-run with redacted_pdf_path for text-layer leak checks; optional sample_pixels=true.
  11. Term search (optional) — POST /agent/word_level_ocr_text_search or word_level_ocr_text_search to find policy phrases in word OCR and whether each hit is boxed.

Pass 1 is complete when pass_strict is true (policy satisfied). `pass_with_cleanup` also requires no suspicious short rows. Run Pass 2 VLM only on `pages_flagged_for_vlm` (policy/visual risk — not pages_needing_csv_cleanup alone).

Automatic post-redaction QA (optional — main app)

When POST_REDACT_PASS1_QA=True (`tools/config.py`), initial redaction (Gradio / CLI / /doc_redact) runs `tools/post_redaction_pass1_qa.py` after writing *_review_file.csv:

  • Emits *_coverage_report.json next to the review CSV
  • Optionally emits sibling *_review_file_pruned.csv when POST_REDACT_PASS1_AUTO_PRUNE=True (does not replace the original CSV)
  • Maps run deny list → must_redact, allow list → must_not_redact when POST_REDACT_PASS1_USE_DENY_ALLOW_LISTS=True
  • Appends a one-line QA summary to the redaction status message

This is pre-review-apply deployment QA only. Agent Pass 1 (policy edits, merge, /review_apply, post-apply coverage) is still required for case-specific review workflows.

Coverage verification (Pass 1 — no VLM)

Programmatic QA replacing per-page visual review for most cases.

CLI:

bash
python tools/verify_redaction_coverage.py merged_review_file.csv ocr_words.csv \
--must-redact "cora|fuller|fyller" \
--must-not-redact "dr\\.|macrae|gibson|social worker" \
--prune-suspicious --pruned-output merged_pruned.csv \
--redacted-pdf output_redacted.pdf \
--output-json coverage_report.json

Report fields:

FieldMeaning
pass / pass_strictPolicy satisfied: no uncovered terms, over-redactions, text leaks, or pixel failures
pass_with_cleanupAlso no suspicious short OCR-fragment rows
pages_flagged_for_vlmPolicy/visual failures → optional Pass 2
pages_needing_csv_cleanupSuspicious rows only → run prune step, not VLM
leak_likely_causes (per page)Why text_layer_leaks appeared — see troubleshooting table above

Agent API: POST /agent/verify_redaction_coverage

json
{
"review_csv_path": "path/to/doc_review_file.csv",
"ocr_words_csv_path": "path/to/doc_ocr_results_with_words_local_ocr.csv",
"must_redact": ["cora|fuller|fyller", "stephen|peter|rhett|yazmin"],
"must_not_redact": ["dr\\.|doctor|social worker|macrae|gibson"],
"redacted_pdf_path": "path/to/doc_redacted.pdf",
"auto_prune_suspicious": true,
"pruned_output_path": "path/to/doc_review_file_pruned.csv",
"sample_pixels": false
}

Response includes coverage_pass_strict, coverage_pass_with_cleanup, pruned_csv_path, prune_log, per-page issues, and pages_flagged_for_vlm vs pages_needing_csv_cleanup.

Split-container verify (Pi agent + separate redaction service)

When the Pi agent and doc_redaction run in separate containers (e.g. http://redaction:7860), path validation in secure_path_utils runs on the redaction server. Agent API paths must resolve under repo root, INPUT_FOLDER, or OUTPUT_FOLDER on that server.

PhaseWhere files liveHow to verify
Pre-applyEdited *_review_file.csv in Pi session workspace; OCR CSV downloaded locallypython tools/verify_redaction_coverage.py <local_review_csv> <local_ocr_words_csv> ... — official CLI on downloaded copies
Post-apply*_redacted.pdf and review CSV on redaction server from /review_applyPOST {gradio_url}/agent/verify_redaction_coverage with server paths from extract_server_paths(review_apply result) plus OCR words path from /doc_redact

Rejected paths (common mistakes):

  • Pi workspace paths (e.g. /home/user/app/workspace/sess/...)
  • /tmp/gradio_tmp/... from /gradio_api/upload (not under OUTPUT_FOLDER)
  • Calling verify_redaction_coverage() from the Pi container with redaction-server path strings

Word search: POST /agent/word_level_ocr_text_search with ocr_words_csv_path, search_text, optional review_csv_path.

covered_by_review_box uses intersecting review boxes (not strict containment). A hit marked false may still be visually redacted if a larger box overlaps — inspect coordinates before adding rows.

Python:

python
from doc_redaction import verify_redaction_coverage, word_level_ocr_text_search
report = verify_redaction_coverage(
"doc_review_file.csv",
"doc_ocr_results_with_words_local_ocr.csv",
must_redact=[r"cora|fuller"],
must_not_redact=[r"dr\."],
redacted_pdf_path="doc_redacted.pdf",
)
hits = word_level_ocr_text_search(
"doc_ocr_results_with_words_local_ocr.csv",
"Fuller",
review_csv_path="doc_review_file.csv",
)

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
52
Repository forks
12
7-day trend score
20

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/seanpedrick-case/doc_redaction/doc-redaction-modifications/badge)](https://verified-skill.com/skills/seanpedrick-case/doc_redaction/doc-redaction-modifications)

Something wrong with this skill or its page? Tell us.