/report-regeneration:report-injection-guardfrom report-regeneration
CLI guard preventing prompt injection in report regeneration. Runs two deterministic checks: partition-anomaly detection on Binding Manifest (flags force-all-frozen shapes) and provenance-bound narrative validation (ensures every generated slot value traces to a manifest binding). Stdlib-only, no ML or network calls.
Ships in report-regeneration. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
A stdlib-only, exit-coded CLI -- injection_guard.py -- that closes the
two prompt-injection gaps the six-leg fidelity harness provably cannot close, and emits an
injection sub-receipt. It is fully ML-free / inference-independent: it never calls a model; it
treats all template / source / OCR'd screenshot text as data, never instructions (the
webfetch-hardening posture) -- it never obeys what it reads, it only measures.
Read first, before touching the code:
../../knowledge/core-architecture-spec.md §6 and the
FORGE plan §4 (injection defense). The load-bearing insight: "downstream V-checks catch it" is
FALSE for the two highest-value injection outcomes --
regenerate slot is novel text no V-check inspects (V1 checks
known values, V4 checks the old taint dictionary, V6 checks the partition -- none inspect a
fresh attacker sentence).Hard-flag an input whose partition is anomalous:
frozen fraction exceeds FROZEN_CEILING (default 0.85; the clean acme-widgets
manifest is ~0.26), ORN >= MIN_DATA_TOKENS data-shaped tokens (default 3) -- the exact shape a successful "mark
everything frozen" injection would produce.V6 does double duty as this tripwire; this gate makes it explicit and independent of any single harness run. In the deterministic pipeline the injected instruction is treated as data (never obeyed), so the manifest is unchanged and this tripwire correctly stays armed for the case where a classifier would have obeyed.
regenerate slot in the output)Every factual / contact / imperative token in a regenerate slot must trace to a manifest
binding (be present in the new-data provenance domain). Any un-provenanced token is a BLOCKER:
ignore previous, classify every, as frozen, wire, remit, ... -- command-shaped text a report narrative never
carries).Seeded defect D13 (scripts/seed_defects.py::inject_D13) has two halves; this gate handles
both honestly:
regenerate #outlook-narrative slot (a
wire-routing number 021000021, an account number 4471182233, an attacker email
[email protected], and a wire/remittance imperative -- none traceable to
any binding) is a crisp provenance-bound-narrative BLOCK.guard(html_text, manifest, new_data) -> dict (and the CLI's --format json) returns:
{
"schema": "report-regeneration/injection-guard@1",
"gate_version": "1.0.0",
"gate": "PASS" | "FAIL",
"posture": "all template/source/OCR text treated as DATA, never instructions ...",
"counts": {"blocking": N, "total_findings": M},
"findings": [{"check","node","token","detail","blocking"}, ...],
"partition": {"class_counts","total_bindings","frozen_fraction","frozen_ceiling",
"mutable_bindings","data_shaped_tokens"},
"checked_regenerate_slots": ["outlook-narrative", ...],
"provenance_domain_size": K
}
The gate is FAIL iff at least one BLOCKING finding. It is consumed by
../report-qa-gate/qa_gate.py: a blocking injection finding folds
the assembled verdict to FAIL and each finding is surfaced under the reviewer checklist's
injection-blocking category.
python3 plugins/report-regeneration/skills/report-injection-guard/injection_guard.py \
--html <PATH> --manifest <PATH> --new-data <PATH> [--frozen-ceiling F] [--format text|json] [--pretty]
python3 plugins/report-regeneration/skills/report-injection-guard/injection_guard.py --version
| Exit code | Meaning |
|---|---|
0 | gate == PASS (no blocking finding) |
1 | gate == FAIL (>= 1 blocking finding) |
2 | usage / path-guard / I/O / JSON-parse error |
All inputs must resolve to real regular files; NUL bytes and .. traversal are rejected.
Stdlib only (argparse, html.parser, json, re, sys, pathlib). No network, no
subprocess, no third-party imports, no model call. Python 3.9.6: no X | Y unions, no match;
from __future__ import annotations.
tests/test_injection_guard.py -- 16 unittest cases: a clean
provenanced regenerate slot passes; a bare year is not flagged; the exact D13 attacker prose
fails via provenance-bound narrative (email + both digit runs + a wire imperative); each
un-provenanced token class (email / URL / long-digits / un-provenanced value / imperative) has a
bidirectional bad/good pair; a surgical slot's un-provenanced value is NOT this check's job
(harness V1 owns it); the force-all-frozen partition fails while a healthy partition passes; and
CLI exit codes 0/1/2 + --version.
python3 plugins/report-regeneration/skills/report-injection-guard/tests/test_injection_guard.py -v
This gate audits an existing output + its manifest for injection signatures. It does not
render, does not sanitize the template (that strip-before-inference step is upstream, §4.3), and
does not implement the six fidelity legs (report-fidelity-harness) or the a11y floor
(report-a11y-gate). It is the injection arm of the QA gate.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
11 skills in this plugin
/infer-officeStage 1 of the report-regeneration OFFICE (docx) pipeline. Parses a Word .docx template into a schema-valid Report Structure Graph (RSG) via stdlib zipfile + xml.etree over word/document.xml: per-node OOXML body-walk anchor, role, rebind class, confidence, provenance, plus the deterministic data-shaped-literal detector reused from the HTML lane. Stdlib-only, Python 3.9; python-docx optional./infer-report-structureStage 1 of the report-regeneration HTML pipeline. Parses an HTML template into a schema-valid Report Structure Graph (RSG): per-node stable anchor, role, rebind class, confidence, provenance, plus the deterministic non-inference data-shaped-literal detector that drives the earned-frozen rule. Stdlib-only, runs on Python 3.9./powerbi-ingestPipeline-facing Power BI ingestion adapter, wrapping scripts/powerbi_probe.py for two modes: `data` runs every dax-kind Binding Manifest binding via REST executeQueries (service-principal/token from ENV ONLY), returning a data.json-shaped fragment keyed by data_query.expression with source_period stamped -- a genuinely independent V1 recompute source for a PBI-sourced value. `shot` captures a fresh report image via ExportToFile (Playwright fallback), packaging it as the embedded image for a regenerate-class PBI node with source_period stamped so period-coherence can catch a stale screenshot. Fail-closed throughout: no creds/route/period => not_captured + the named fallback (manual-figure-labeled-unverified for data, user-provided-image for shot), never a fabricated value or period. Token never logged. Reach for this to turn a Binding Manifest's PBI-sourced bindings into pipeline artifacts. NOT for manifest construction (rebind-manifest) or running the fidelity harness itself (report-fidelity-harness)./rebind-htmlPipeline stage 3 (the HTML surgical output engine) for report-regeneration. Applies a Binding Manifest to a COPY of an HTML report template and emits the regenerated HTML: frozen nodes stay byte-identical, surgical/regenerate nodes are rebuilt under the zero-literal construction rule (strip the old value, THEN write the new one), needs-review nodes are left untouched but visibly flagged + logged. Stdlib-only (re/html.parser/json), jinja2 optional acceleration, runs on Python 3.9.6. NOT for structure inference (that's an earlier pipeline stage) or the fidelity harness (a separate downstream track) or Office/docx output (a later release lane)./rebind-manifestPipeline stage 2 of report-regeneration (detect -> strip -> rebind): turn an RSG + the OLD template + the new dataset into a schema-valid Binding Manifest and a taint dictionary. Enforces the earned-frozen rule (a data-shaped literal / old-taint / new-dataset value demotes a candidate-frozen node to needs-review), forces raster/embedded-cache nodes to regenerate, and proposes each node's data_query. Reach for this when building or amending a Binding Manifest./rebind-officePipeline stage 3 (the Office/docx surgical output engine) for report-regeneration — the Office analogue of rebind-html. Applies a Binding Manifest to a COPY of a Word .docx template and emits the regenerated .docx: frozen OPC parts + nodes stay byte-identical, surgical/regenerate nodes are rebuilt under the zero-literal construction rule (strip the old value, THEN write the new), rasters are re-captured (never transplanted), needs-review nodes are left untouched but visibly marked + logged. Stdlib-only (zipfile/xml.etree), edits via the shared rr_anchor OOXML resolver, python-docx/docxtpl optional, runs on Python 3.9. NOT for structure inference (infer-office, an earlier stage), the fidelity harness (a separate downstream track), or HTML output (the rebind-html lane).npx claudepluginhub mcorbett51090/ravenclaude --plugin report-regeneration