Skip to content

feat(codegen): support Pine drawing objects as data - #27

Merged
luisleo526 merged 2 commits into
mainfrom
feat/drawing-objects-as-data
Jun 29, 2026
Merged

luisleo526 merged 2 commits into
mainfrom
feat/drawing-objects-as-data

Conversation

@luisleo526

Copy link
Copy Markdown
Contributor

Summary

  • Add Pine v6 drawing-object lowering for line/box/label/linefill/chart.point as headless data structures.
  • Preserve visual args as accepted no-ops while emitting real geometry/handle operations through the engine drawing runtime.
  • Keep non-drawing output gated/byte-identical and add defensive support-checker errors for unsafe drawing-handle history.

Related

Scope / caveats

  • Fixes the corpus compile/run unblock for egoigor; matched trades are price-exact, but this PR does not claim egoigor trade-for-trade parity.
  • box data path is covered by a synthetic probe; full doriannnq remains blocked by cross-symbol request.security.
  • Commit message mentions DRAWING_RETURN_SPECS, but implementation intentionally keeps return inference inline; see PR body and tests as source of truth.

Verification

  • python -m pytest tests/test_support_checker.py tests/test_codegen_drawing_data.py -q
  • PINEFORGE_ENGINE_INCLUDE=../pineforge-engine/include python -m pytest -q
  • python ../pinescript-scrapper/scripts/verify-engine-local.py egoigor1976-1-trendline-strategy → OK, match 20/44tvWin, px 100.0%, eng=59
  • Emitted-C++ diff vs origin/main over current corpus: 245/245 non-drawing strategies byte-identical; drawing-touching changes only where expected; 0 transpile errors

luisleo526 and others added 2 commits June 29, 2026 10:50
….point)

Pine v6 drawing geometry becomes real C++ state via a value-view handle
over a per-type DrawingArena; every visual kwarg (color/style/width/
bgcolor/text_*/extend/force_overlay) is accepted and dropped. All new
behaviour is gated on _uses_drawing, so non-drawing strategies emit
byte-identical C++ (245/246 engine parity unchanged).

- tables.py: DRAWING_TYPE_TO_CPP / DRAWING_NS / DRAWING_STYLE_NS; remove
  line/box/label/linefill/polyline from SKIP_NAMESPACES (table kept)
- base.py: shrink _DRAWING_TYPES_INIT to {table,polyline}; _detect_drawing_usage
  + _compute_drawing_caps (max_lines/boxes/labels/polylines_count); arena members
- codegen/types.py + analyzer/types.py: udt(line/box/...) -> Line/Box/...;
  DRAWING_RETURN_SPECS so *.new/*.copy/get_line* type as handles
- new codegen/drawing.py + visit_call.py: DRAWING_DISPATCH at all four receiver
  sites incl. the arbitrary-expression receiver (arr.get(i).delete()); user
  methods on drawing types fall through (L.1 precedence); chart.point inline
  aggregate lowering; point-form overload selection; geometry-only ctor kwarg filter
- visit_expr.py: DRAWING_STYLE_NS const reads -> "0" (.all exempted)
- emit_top.py: drawing.hpp include; udt-method drawing self/param/return mapping
- support_checker.py: SUPPORTED_LINE/BOX/LABEL/LINEFILL/CHART_POINT

Unblocks egoigor1976-1-trendline-strategy (the corpus's sole geometry
read-back). pytest: 1321 passed, 0 failed (was 1312; +9 drawing tests).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@luisleo526
luisleo526 merged commit c210fa0 into main Jun 29, 2026
9 checks passed
@luisleo526
luisleo526 deleted the feat/drawing-objects-as-data branch June 29, 2026 03:25
luisleo526 added a commit that referenced this pull request Oct 5, 2026
…he scoreboard README at pineforge-release 03b8dcc (#171)

* Read diagnostic codes off their text in linear time

The classifier fullmatched each catalog template as a regex with lazy
(.*?) arguments over the message and hint. Text a script spells reaches
those arguments, and with several arguments the regex backtracked over
every split: 0.55 s for 1.8 KB and 23 s for 3.4 KB of one template's text.

Each literal now goes to its leftmost place after the previous one, the
last to the text's end. That is the split the lazy regex returns, and the
only one tried when no argument name repeats, since a leftmost place leaves
the rest the most room. Where a name repeats (a receiver in the message and
the hint), later places are tried in the regex's order within a budget of
4,096 places. The same crafted text, grown to 6.6 MB, now classifies in
milliseconds.

Codes and args are unchanged:
- 669 distinct real texts (corpus, fixtures, suite);
- 7,512 generated samples, plain and holding the templates' own literals;
- tests/test_diagnostic_codes.py now pins equality with a reference
  lazy-regex matcher, and a timing bound on flooded text.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Keep two tests off a loaded host's clock

test_array_history.py::test_many_bindings_are_walked_once_each had a 40 s
wall-clock budget. It takes 13-14 s alone on our shared Linux test hosts, yet
every full-suite xdist run there since #166 failed it at 50-60 s. One such run,
timing three transpiles, read 58, 57 and 78 s of wall clock for 27, 27 and 33 s
of CPU at load 45-74: the wall clock counted the worker's wait for a CPU. The
test now budgets 60 s of CPU time, 1.8 times the most measured under that load.
The regression it guards, a walk of the rest of the script per binding, costs
about eight times today's time on any host.

test_every_spelled_template_has_a_code loaded scripts/gen_diagnostics_catalog.py
into the test process, and the generator's parse of every module of the package
then stayed in that xdist worker for the rest of the suite. The test now runs the
generator's own check (its default mode, the same comparison) in a subprocess,
and shows the templates without a code when it fails. That move alone left the
timing test at 50.3 s in the next full-suite run.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* License: the PineForge Source License 1.1; distributing the software bundled with a product is Commercial Use

The Distribution License said "Distributing copies under this section is not
Commercial Use", while Commercial Use (3) made embedding the software or its
Output into a product or service made available to others Commercial Use. A
vendor shipping the unmodified transpiler with or inside its product could
argue that it only distributed copies and owed nothing.

1.1 closes that, and changes nothing else:
- Distribution License: unless it is a permitted purpose, distributing the
  software, changed or not, embedded in or bundled with a product or service
  made available to others is Commercial Use under (3), which the license to
  distribute does not cover. Every other distribution of copies stays free and
  is not Commercial Use, as before (sharing copies, forks, mirrors, package
  registries).
- Commercial Use (3): embedding the software or its Output, changed or not,
  or distributing either bundled with such a product or service.
- Personal Trading, noncommercial purposes and organizations, personal uses,
  the Notices duty and Output are unchanged.

Surfaces: the LICENSE header, README (name and the Commercial Use bullet),
LEGAL.md (name, and one line: 1.1 replaces 1.0 for the code on main and in
future releases, and what changed), the pyproject.toml comment, AGENTS.md and
CLAUDE.md. Releases up to and including 1.1.0 keep the license text they
shipped with.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* docs: render the active scoreboard from the facts tokens at pineforge-release 03b8dcc

Re-render the marked README values against the hub's canonical facts at 03b8dcc
(the squash of release hub #27): the active scoreboard is
pineforge-parity-baseline-20261004-engine-6b77f061 (engine 6b77f061, codegen
285ac03), 7,970 excellent / 19 strong of 7,989 graded, none below strong.
Release scoreboards keep their own numbers. Only values inside pf markers change.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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