O que pathway-figure-ledger faz?
Biological mechanism / signalling pathway figure with a source ledger. Input: the case's source material (paper PDF, text, data tables, an SVG to edit) and artifacts/figure-workorder.json. Output (/app/output): figure.svg (layered, editable text), figure.png, figure.pdf, figure.source.json (the spec that rebuilds it),
source_map.md|json (every element -> the source text it came from), edit_record.md|json (versions + element diff), issues.json, result.json (all output_contract fields + case_id).
Arrow semantics decide whether the figure is right: activation ->, inhibition -|, binding o-o, phosphorylation ->(P), translocation dashed, feedback dashed; type and direction come from the source sentence. Nothing here calls a model or the network; every element is checked against the sources by rules, and an element that fails is left out of the figure and listed.
Budget: 64 model requests, 900 seconds - plan for about 8-12 requests
| step | requests | what |
|---|---|---|
| 1 | 1 | prepare: prints the work order, finds and indexes the sources, lists candidate relations / tables, and delivers a first figure at once (flagged DRAFT until you replace it) |
| 2 | 1-3 | read the sentences / cells that matter (read E012 fig:2 D:table) |
| 3 | 1-3 | spec blocks (the whole figure in one or two calls); read the verification printout and fix errors |
| 4 | 1 | make (final build, records, result.json) |
After ~600 s run make and stop. status shows the time used. |
Quick start (SK = directory of this file)
SK=/skills/weekly-skill
python3 $SK/scripts/figctl.py prepare # work order, sources (sections / figures / tables / data tables), relation candidates, KIND, export constraints
python3 $SK/scripts/figctl.py read E012 fig:2 # exact source text, by anchor (D:table#r3cValue for data cells)
python3 $SK/scripts/figctl.py spec <<'EOF' # the figure as blocks; verified and rebuilt at once (see "Spec blocks")
=== node a
label: Name as in the source
kind: protein
source: @E012.1
=== edge e1
from: a
to: b
type: activates
source: @E012.1
EOF
python3 $SK/scripts/figctl.py make # final: exports + source map + edit record + result.json
A complete worked spec (with its invented source in examples/input/) is examples/spec.txt: read it before writing yours; examples/output/ shows the records it produced.
Other commands: cites 3 / cites Wnx7 (every sentence that mentions Figure 3 / a name: start here when the work order names a figure), format (all block fields), rels (relation candidate sentences), check, status, versions, diff, rollback --to v002, inventory + edit (SVG that came with the task), probe, mode kind=<kind>; python3 $SK/scripts/selftest.py (about 20 s).
prepare prints the raw work order and case.json: they fix the kind of figure, formats, size and any constraints. The work order wins. Paths: FIGCTL_INPUT /input, FIGCTL_WORK /app/work/figctl, FIGCTL_OUT /app/output.
Spec blocks (all fields: figctl.py format or references/spec-format.md)
=== figure (kind, title, width_mm, dpi) | === group <id> (label, kind compartment|container|lane, order, parent) | === node <id> (label, alias, kind, group, badge, source) | === edge <id> (from, to, type, label, source) | === chart <id> | === panel <id> | === drop <id>.
A block with an existing id replaces it. source: @anchor is required on every node, edge and claim: the label must occur in the cited text, an edge needs both endpoints in the cited sentence with the stated relation word, numbers and units must be the source's.
Your own wording: generic: yes (allowed, listed in exceptions). A deliberate choice that triggers a warning: ack: reason.
What is verified (full list: references/checks.md)
| check | meaning |
|---|---|
| source_grounding | every node / edge / group / card has an anchor that exists; label (or alias) occurs in the cited text; endpoints of an edge occur in the cited text; quotes are verbatim |
| relation_type_and_direction | the edge type matches the relation word of the sentence (activates / inhibits / binds / ...), direction vs active / passive voice, location cues, step order, flow start / end |
| numbers_units_provenance | numbers, units, error-bar kind in labels / callouts / charts are in the cited text or the table |
| data_mapping_readback | charts: each mark read back through the axis equals its table cell; zero-based bars, clipped axes, duplicates, legend = series |
| layout_and_text_fit | nothing overlaps, text fits its box and the canvas, containers do not interleave, edges avoid nodes |
| contrast_and_print_size | text contrast >= 4.5:1, smallest text in pt at the print width |
| png / pdf / svg export, fonts | pixels not blank / clipped; PDF vector, text selectable, fonts embedded; SVG valid, layered, unique ids, text editable; CJK font present when needed |
| deterministic_rebuild, edit_record | the saved spec rebuilds the identical SVG; every version has an element-level diff |
An element with an error is NOT drawn (it stays in figure.source.json): fix it and resend the block. The figure never shows what the sources do not support. |
Pathway: specifics
- Compartments are
groupblocks withkind: compartmentand anorder:from outside to inside (1 extracellular, 2 membrane, 3 cytoplasm, 4 nucleus ...); the cascade is laid out along that order. An upstream node placed below its target getsUPSTREAM_BELOW. - Edge types.
activates(promotes, induces, upregulates),inhibits(represses, blocks, antagonises),binds(interacts, recruits, dimerises),phosphorylates,transports(translocates, imports),produces,feedback. The source sentence must carry a cue word of that family; a sentence that says activates under aninhibitsedge isRELATION_TYPE_MISMATCH. - Direction. Active voice: subject -> object. Passive (
X is inhibited by Y): Y -> X. The checker looks at the nearest mention pair and warns (DIRECTION_CHECK); acknowledge a deliberate choice withack: reasonon the edge. - Genes vs proteins.
kind: geneis italic; human symbols are CAPITALS, mouse symbols capitalised (species: human|mousein the figure block); protein names are not italic. - Feedback. Mark the closing edge of a loop with
route: feedback(drawn dashed, kept out of the layering) so that the cascade still reads top to bottom. - Location. A receptor in the cytoplasm band, or a node placed where the cited clause says otherwise, gives
LOCATION_CHECK. - Indirect / inferred relations:
confidence: indirectdraws the edge dashed; say so in the label or legend.
Editing
- Own figure: resend the blocks that change (
=== node a... or=== drop a); addreason:to the block.figctl.py diffshows the element ids added / removed / changed; unchanged elements keep geometry, text and source anchors. - An SVG that came with the task is the source:
figctl.py inventorylists elements,figctl.py editapplies=== editblocks (set_text, set_attr, recolor, move, delete, add_text) in place, refuses an edit that invents a number, andmakeproves the rest is byte-identical (edit_record.md: leaf elements untouched).
Outputs
figure.svg figure.png figure.pdf (+ figure.tiff / .eps only when the work order asks) figure.source.json source_map.json|md datamap.csv|json (charts) edit_record.json|md issues.json change_log.md result.json.
status: success only if nothing failed and the figure is not a draft; partial (reasons in exceptions); failed (no figure); cannot_determine (no readable source).
Exceptions to report, never hide
a draft not yet replaced - elements left out because verification failed - generic labels - warnings not acknowledged - values computed (mean of listed rows) - cells not drawn (empty / non-numeric) - fonts missing or substituted - EPS / CMYK limits - print size too small - parser warnings. All land in result.json -> exceptions.
Dependencies
Python 3.9+, pymupdf, Pillow, lxml, numpy (optional: openpyxl for XLSX, OCR for scanned PDFs, LibreOffice / rsvg-convert / inkscape only to export an SVG that came with the task). figctl.py probe reports what exists. A Latin font file (Arial, Liberation Sans or DejaVu) is needed; a CJK font for Chinese labels.
Examples and honesty notes
examples/ has an invented source, the spec, the failure-path spec, and the real outputs of that run (an example, not an organiser case, not a score). README.md lists what was tested and what was not.