/report-regeneration:infer-report-structurefrom report-regeneration
Parses HTML templates into a Report Structure Graph (RSG) with stable anchors, semantic roles, and a deterministic data-shaped-literal detector for the report-regeneration pipeline.
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.
The first stage of the report-regeneration HTML pipeline. It reads an HTML report
template and emits a Report Structure Graph (RSG) — a format-neutral ordered tree that
downstream stages (binding-manifest generation, surgical rebind, the fidelity harness) address
and verify against. The RSG is an addressing-and-verification structure, NEVER a generator
(knowledge/core-architecture-spec.md §2).
infer.py walks the template in document order (order is load-bearing — the V2 frozen-
complement diff and V3 re-inference isomorphism both depend on it) and emits one RSG node per
element. Each node validates against knowledge/rsg.schema.json
and carries:
| Field | Source |
|---|---|
anchor | a stable node identity — element_id when the element has an id, else a css_selector built from nth-of-type steps anchored at the nearest id-bearing ancestor. Never a raw char-offset (RT1-F10). |
role | rule-based semantic role (kpi-value/table-cell/narrative/chart/image/period-label/heading/metadata/static-chrome/unknown). |
class | rebind class (frozen/surgical/regenerate/needs-review). |
confidence | 0–1; sub-threshold ⇒ needs-review. |
provenance | method (native-parse/rule-based/llm-labeled), source, source_period, and pbi_route (xmla/rest/screenshot/null) for Power-BI-sourced nodes. |
data_shaped_literal | output of the pinned, non-inference, deterministic detector. |
data_shaped_literaldetect_data_shaped_literal(text) flags currency / number / date / percent / unit /
known-entity shapes deterministically. It is intentionally blind to meaning: it cannot tell
100% the marketing tagline from 100% the KPI, or Fiscal Year 2024 the static citation from a
data-bound period — and it must not try. That is exactly why it is the right tool for the
earned-frozen rule (§4): any data-shaped literal in a candidate-frozen node force-demotes
it to needs-review, regardless of classifier confidence. It is independent of the LLM-accuracy
ceiling.
regenerate (a transplanted binary cannot be
proven data-free). This holds even when the fixture annotates the image data-role="frozen"
(e.g. the header logo, the Power BI screenshot).frozen node FORCE-DEMOTES
it to needs-review.Semantic role/class labeling here is a rule-based STUB (method: "rule-based") that reads the
fixture's explicit annotation scheme (data-role / data-bind / data-shape / data-period /
data-section-role / data-source). There is no live LLM call — the model-assisted slot
labeling of §2 lands in a later stage.
# From the repo root (paths are relative + path-guarded, or an in-repo absolute path):
python3 plugins/report-regeneration/skills/infer-report-structure/infer.py \
--in tests/fixtures/report-regeneration/sample-report.html \
--out tests/fixtures/report-regeneration/_out/rsg.sample.json
# JSON summary on stdout (exit-coded: 0 ok, 2 usage/path/parse/schema error):
python3 .../infer.py --in <template.html> --out <rsg.json> --format json
Flags: --in, --out (required), --template-id (default: input filename stem),
--confidence-threshold (default 0.6), --format {text,json}.
tests/fixtures/report-regeneration/new-data.sample.json
holds plausible NEW-period (Q2 2025) values keyed to every data-bind in the corpus, so the
downstream rebind/harness stages and the acceptance test share one consistent new dataset.
Stdlib-only (argparse/html.parser/json/re/os/sys), runs on Python 3.9.6 with no pip
installs; lxml/selectolax are optional acceleration via a graceful try/import that changes
nothing when absent. No network, no subprocess. Path-guarded (rejects .. and repo-escape,
mirroring svg-report-lint.py). The emitted RSG is validated against rsg.schema.json before it
is written — an invalid build refuses to write and exits 2.
tests/test_infer.py asserts the sample report parses, the RSG validates
against the schema, every data-bind node is found, the detector flags the tricky cases (a year,
a percent-shaped tagline), the earned-frozen demotion fires, and the companion new-data fixture
covers every binding. Runs under pytest or as a plain script (python3 tests/test_infer.py)
so it needs no third-party test runner.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
report-structure-graph, html-parsing, data-extraction, pipeline, rsg, frozen-rule
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./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)./report-a11y-gatereport-regeneration a11y gate: a11y_lint.py is a stdlib, machine-checkable WCAG-subset linter over an output HTML deliverable (the Tier-A a11y FLOOR, not axe-core/veraPDF -- that is the later Tier-B upgrade). BLOCKING rules: img-alt (non-decorative <img> with no alt), html-lang, link-name, button-name, control-label, table-headers. ADVISORY -> manual residue: th-scope, heading-order. Catches seeded defect D3 (missing alt-text) as a crisp img-alt BLOCK. Emits a sub-receipt folded into report-qa-gate (blocking a11y violation -> assembled verdict FAILs; manual residue -> reviewer checklist). HONEST about the ~30-50% machine-checkable floor: the rest is manual residue, never claimed passed. Stdlib-only, exit-coded, path-guarded, no network/subprocess.npx claudepluginhub mcorbett51090/ravenclaude --plugin report-regeneration