pineforge-codegen 1.9.1__tar.gz → 1.10.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/CHANGELOG.md +73 -0
  2. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/CONTRIBUTING.md +10 -5
  3. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/PKG-INFO +1 -1
  4. pineforge_codegen-1.10.0/VERSION +1 -0
  5. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/docs/PUBLIC_CONTRACT.md +30 -0
  6. pineforge_codegen-1.10.0/docs/ci.md +126 -0
  7. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/__init__.py +37 -4
  8. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/analyzer/base.py +1442 -28
  9. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/analyzer/call_handlers.py +63 -5
  10. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/analyzer/contracts.py +11 -0
  11. pineforge_codegen-1.10.0/pineforge_codegen/analyzer/operators.py +276 -0
  12. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/analyzer/types.py +261 -91
  13. pineforge_codegen-1.10.0/pineforge_codegen/analyzer/value_bindings.py +359 -0
  14. pineforge_codegen-1.10.0/pineforge_codegen/codegen/array_field_width.py +441 -0
  15. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/base.py +57 -18
  16. pineforge_codegen-1.10.0/pineforge_codegen/codegen/bool_text.py +337 -0
  17. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/capabilities.py +8 -19
  18. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/collection_history.py +2 -1
  19. pineforge_codegen-1.10.0/pineforge_codegen/codegen/color_constants.py +89 -0
  20. pineforge_codegen-1.10.0/pineforge_codegen/codegen/constant_fold.py +338 -0
  21. pineforge_codegen-1.10.0/pineforge_codegen/codegen/constant_values.py +173 -0
  22. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/drawing.py +21 -19
  23. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/emit_top.py +37 -31
  24. pineforge_codegen-1.10.0/pineforge_codegen/codegen/endless_for.py +507 -0
  25. pineforge_codegen-1.10.0/pineforge_codegen/codegen/for_loops.py +17 -0
  26. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/graph_journal.py +3 -11
  27. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/helpers.py +47 -1
  28. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/host_members.py +2 -0
  29. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/input.py +16 -47
  30. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/order_shapes.py +70 -2
  31. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/security.py +1942 -76
  32. pineforge_codegen-1.10.0/pineforge_codegen/codegen/strategy_declaration.py +184 -0
  33. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/tables.py +10 -4
  34. pineforge_codegen-1.10.0/pineforge_codegen/codegen/timeframe_values.py +370 -0
  35. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/types.py +1231 -190
  36. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/visit_call.py +249 -113
  37. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/visit_expr.py +202 -66
  38. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/visit_stmt.py +307 -51
  39. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/collection_history.py +26 -15
  40. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/diagnostics_catalog.json +59 -0
  41. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/errors.py +17 -0
  42. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/external_requests.py +3 -2
  43. pineforge_codegen-1.10.0/pineforge_codegen/function_overloads.py +337 -0
  44. pineforge_codegen-1.10.0/pineforge_codegen/intrinsic_binding.py +50 -0
  45. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/lexer.py +140 -22
  46. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/library_inline.py +5 -0
  47. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/library_modules.py +2 -0
  48. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/limits.py +6 -0
  49. pineforge_codegen-1.10.0/pineforge_codegen/loop_types.py +468 -0
  50. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/method_binding.py +48 -3
  51. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/parser.py +179 -98
  52. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/security_contexts.py +136 -27
  53. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/signatures.py +153 -27
  54. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/support_checker.py +47 -17
  55. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/symbols.py +30 -0
  56. pineforge_codegen-1.9.1/VERSION +0 -1
  57. pineforge_codegen-1.9.1/pineforge_codegen/codegen/constant_fold.py +0 -131
  58. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/.gitignore +0 -0
  59. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/LEGAL.md +0 -0
  60. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/LICENSE +0 -0
  61. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/README.md +0 -0
  62. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/docs/codegen-coverage-gaps.md +0 -0
  63. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/docs/pine-cap-activation.md +0 -0
  64. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/analyzer/__init__.py +0 -0
  65. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/analyzer/diagnostics.py +0 -0
  66. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/analyzer/tables.py +0 -0
  67. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/ast_nodes.py +0 -0
  68. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/block_locals.py +0 -0
  69. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/builtin_keywords.py +0 -0
  70. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/__init__.py +0 -0
  71. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/ascii.py +0 -0
  72. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/checked_settings.py +0 -0
  73. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/closed_trade_fold.py +0 -0
  74. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/helpers_syminfo.py +0 -0
  75. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/history_sharing.py +0 -0
  76. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/id_sites.py +0 -0
  77. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/run_stops.py +0 -0
  78. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/session_market.py +0 -0
  79. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/ta.py +0 -0
  80. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/codegen/tv_number_format.py +0 -0
  81. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/cpp_allowlist.py +0 -0
  82. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/cpp_names.py +0 -0
  83. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/diagnostic_codes.py +0 -0
  84. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/finite_ta_length.py +0 -0
  85. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/library_v5.py +0 -0
  86. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/matrix_overloads.py +0 -0
  87. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/pine_libraries.py +0 -0
  88. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/pine_spelling.py +0 -0
  89. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/pragmas.py +0 -0
  90. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/request_discovery.py +0 -0
  91. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/request_feed_inventory.py +0 -0
  92. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/session_reads.py +0 -0
  93. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/timeframe_token_cli.py +0 -0
  94. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/tokens.py +0 -0
  95. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pineforge_codegen/tv_input_choices.py +0 -0
  96. {pineforge_codegen-1.9.1 → pineforge_codegen-1.10.0}/pyproject.toml +0 -0
@@ -20,6 +20,79 @@ supported as exact pairs; on the 0.x line they are independent. See the
20
20
  the release commit. A prerelease note describes changes since the preceding
21
21
  prerelease or stable tag; the final stable note consolidates the series.
22
22
 
23
+ ## Unreleased (next release)
24
+
25
+ - An affine chart loop proved endless is stopped with the loop-time error when
26
+ its result reaches an effect. Omission is limited to an unused loop statement
27
+ with no calls, whose writes have no readers except self-updates, a break
28
+ condition or one further unused variable declaration. Other flagged loops
29
+ stop when their result is read in a shape not measured, where TradingView
30
+ may drop them. Endless loops in functions, methods and `request.security`
31
+ still never end here while TradingView stops them; data-dependent endless
32
+ loops still hang.
33
+ - Pine v6 calls refuse a positional argument after a named argument with
34
+ `PF-E2074` at that positional expression. The check also covers strategy
35
+ declarations, unused functions and v6 library bodies before lowering.
36
+ - A v6 counted loop whose start has positive int check evidence now refuses a
37
+ float-typed step during translation with `PF-E2079` at the step expression
38
+ and the hint "Use an int step or a float counter." An unknown start with
39
+ a positively float step still selects a float counter.
40
+ - Counted loops can read their own counter in the end and step expressions,
41
+ including when it shadows an outer binding and inside a `request.security`
42
+ helper. The counter now wins over an outer same-named variable. The step is
43
+ read once at counter 0. TradingView measurements establish that direction
44
+ is fixed from the start and the first end read at counter 0, then an end
45
+ that reads this counter is read again at the start before the first
46
+ continuation test. The v6 end also refreshes between iterations. A non-positive
47
+ v6 step stops the run instead of being converted into a positive step.
48
+ This changes generated C++ for explicit-step loops; regenerate and
49
+ relink affected strategies.
50
+ - A v6 counted loop uses a float counter when its start has positive float
51
+ evidence, or when its start is unknown and its step has positive float
52
+ evidence, including inside a `request.security` helper. A start whose value
53
+ has positive int evidence keeps an int counter. Without float evidence, the
54
+ existing int route is unchanged; v5 library loops keep their existing
55
+ int-counter route.
56
+ Counter-family inference follows declaration sources in a dedicated query,
57
+ independently of shared expression and storage inference.
58
+ A division in a loop start keeps its fraction unless it is a constant
59
+ division with an exact integer result, which keeps the int route. The float-step
60
+ refusal follows TradingView's check type (a division of two ints is int).
61
+ - Float-counter loops accumulate the counter by repeated double addition.
62
+ TradingView's measured loop-end rule admits a counter whose excess beyond
63
+ the end, computed as one double subtraction in the loop's direction, is
64
+ strictly below `1e-10`. The named value `kTvFloatStepEnd` is emitted only
65
+ for float-counter loops. Measured on TradingView at the 0.3 scale (counted
66
+ up to a 9.999e-11 shortfall, not counted from 1.0e-10) and at counter
67
+ magnitudes of about 1, 1e3, 1e6 and 1e9; no magnitude-independent constant
68
+ is claimed; not a constant TradingView publishes.
69
+ `0.0 to 0.3 by 0.1` counts four iterations;
70
+ `0.0 to 2999.9999999999 by 1000.0` counts three.
71
+ A positive infinite step exits after one iteration with a finite end
72
+ and needs no non-finite-step guard.
73
+ - Known loop gaps: a float counter passed to
74
+ an untyped helper truncates here, while TradingView passes the fractional
75
+ value (accumulating `twice(x)` from 0.0 to 1.0 by 0.25 gives 2 here and 5
76
+ on TradingView). `array.from(x)` can also truncate a float counter through
77
+ inferred `array<int>` storage. An unknown start from an untyped parameter
78
+ with a positively float step now selects a float counter, independently
79
+ of shared parameter inference. For `f(x)` containing
80
+ `for v = x to 1.0 by 0.25`, TradingView refuses `f(0)` with CE10106 and
81
+ accepts `f(0.0)`. PineForge accepts and runs both with a float counter
82
+ because this inference cannot distinguish their call-argument types;
83
+ refusing the unknown start would also refuse the valid float-argument call.
84
+ Block-local/enclosing-counter bindings and stops inside `request.security`
85
+ have no TradingView tape.
86
+ - A Pine v6 function or method reading a later local without an earlier
87
+ visible binding is refused during analysis at the read (`PF-E2075`),
88
+ using the same declaration-order rule as later globals (`PF-E2053`).
89
+ Reading a loop counter or `for ... in` binder after its loop without
90
+ another visible binding is now refused at translate time (`PF-E2054`);
91
+ these reads were previously accepted.
92
+ TradingView accepts a namespace call after an expired block local with the
93
+ same name; PineForge's analysis no longer refuses it, but code generation
94
+ still rejects some such calls (a known gap).
95
+
23
96
  ## 1.9.1 — 2026-10-31
24
97
 
25
98
  - Translation checks the generated C++ against a fixed allowlist and refuses a
@@ -196,11 +196,16 @@ declare the environment fails at npm.
196
196
  engine.
197
197
  - Keep [CHANGELOG.md](CHANGELOG.md) current for user-visible changes. Its
198
198
  release-note policy applies to both stable and prerelease tags.
199
- - CI clears a pull request from a fork into `main` only when it changes
200
- documentation or legal text alone (Markdown, `docs/`, `LICENSE`, `NOTICE`).
201
- A fork's code change does not run in CI here: its `gate` check fails until a
202
- maintainer pushes the branch to this repository and opens a pull request
203
- from it, which runs the full gate.
199
+ - Pull request CI requires a non-draft, same-repository PR to `main`, with
200
+ repository write permission for its author, actor and rerunning actor (or a
201
+ fixed allowed bot). Fork PRs, including documentation-only PRs, do not enter
202
+ GKE. A maintainer can push the branch to this repository and open a PR from
203
+ it. Every admitted diff runs the full test matrix and differential gate.
204
+ See [CI admission and check mapping](docs/ci.md) for the hosted authorization
205
+ and result jobs, pod permissions, and operator setup.
206
+ - `test.yml` runs only on push to `main` and manual dispatch. Its `workflow-lint`,
207
+ `package-files` and `pytest` jobs use `gke-8cpu-16gb-amd64`; `authz`, `changes`
208
+ and `test-check` use `ubuntu-24.04`.
204
209
  - The README describes the latest release and becomes the PyPI page of the
205
210
  next release: when a version is tagged, update its "Releases and this
206
211
  README" section, its engine-pairing table and its release markers.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pineforge-codegen
3
- Version: 1.9.1
3
+ Version: 1.10.0
4
4
  Summary: PineScript v6 to C++ transpiler that targets the pineforge-engine runtime.
5
5
  Project-URL: Homepage, https://github.com/pineforge-4pass/pineforge-codegen-oss
6
6
  Project-URL: Issues, https://github.com/pineforge-4pass/pineforge-codegen-oss/issues
@@ -0,0 +1 @@
1
+ 1.10.0
@@ -457,6 +457,12 @@ or generation error; its `diagnostics` attribute carries `Diagnostic` objects.
457
457
  1.5.0) notes; use `transpile_full()` to read them. The `diagnostics` of a
458
458
  `CompileError` can carry them beside its errors.
459
459
 
460
+ A counted-loop counter is visible in its loop's end and step expressions
461
+ and its body, but not after the loop. A `for ... in` binder is local to the
462
+ loop body. Reading either outside its scope raises analyzer `PF-E2054` at
463
+ the identifier, unless an enclosing declaration or builtin supplies that
464
+ name. Reassigning a name with no visible declaration retains `PF-E2020`.
465
+
460
466
  `transpile()`, `transpile_full()` and `transpile_with_request_inventory()` check
461
467
  the generated C++ allowlist even with `check_support=False` and raise
462
468
  `CompileError` with at most 20 fixed reasons at `filename:1:1` when it reports
@@ -469,6 +475,12 @@ read through the script's own requests manifest when `$PINEFORGE_PINE_LIBRARIES`
469
475
  and `$PINEFORGE_REQUESTS_ROOT` name one. An import with no source is refused by
470
476
  name, except one whose alias is `ta`, `math` or `str` and that names only that
471
477
  namespace's built-ins, which is a no-op.
478
+ Library imports are supported only when the library source is supplied;
479
+ otherwise compilation fails with the diagnostic above.
480
+ Unresolved imports carry a hint about supplying or inlining the library source:
481
+ `PF-E2040` without a resolver reason, `PF-E2041` with one. The message text and
482
+ named arguments are unchanged. `PF-E2018` and `PF-E2019` remain catalog entries
483
+ for the forms without a hint.
472
484
 
473
485
  `transpile_full()` runs the same translation once and returns these keys on
474
486
  success:
@@ -626,6 +638,24 @@ argument.
626
638
 
627
639
  ## Diagnostic codes
628
640
 
641
+ Pine v6 call arguments must put all positional arguments before named
642
+ arguments. `PF-E2074` is a fatal analyzer diagnostic at the first positional
643
+ expression that follows a named argument in the same call. It covers calls
644
+ and strategy declarations before argument rewriting or unused-code removal,
645
+ including v6 library bodies, and remains enforced with `check_support=False`.
646
+ Nested calls have independent argument lists; all-named calls may name
647
+ parameters in any order. Imported v5 libraries retain their existing policy.
648
+
649
+ Callable value reads follow declaration order. A Pine v6 function or method
650
+ reading a later local without an earlier visible binding reports `PF-E2075`
651
+ at that identifier; a later direct global retains `PF-E2053`. Earlier outer
652
+ bindings remain visible before a local shadow is declared.
653
+
654
+ A Pine v6 `for` loop whose counter start has positive int evidence reports
655
+ `PF-E2079` for a float-typed step. This fatal analyzer diagnostic points at the
656
+ step expression, with the hint "Use an int step or a float counter."
657
+ Unknown starts are not refused by this diagnostic.
658
+
629
659
  Every `Diagnostic` (in `transpile_full(...)["diagnostics"]`, in a
630
660
  `CompileError`'s `diagnostics`, and in the glue envelopes) carries the stable
631
661
  `code` and `args` introduced in 1.2.0. Since 1.5.0 it also carries
@@ -0,0 +1,126 @@
1
+ # Pull request CI
2
+
3
+ `gke-pr.yml` runs pull request tests on GKE runner pods after a hosted admission
4
+ job accepts the exact head. It uses `pull_request_target` against `main`, so
5
+ GitHub executes the workflow definition from the base repository. Candidate
6
+ workflow files are fetched as data and checked by the base tree's
7
+ `tests/test_gke_pr_admission.py`; the hosted jobs never check out candidate code.
8
+
9
+ Admission requires an open, non-draft PR from this repository, with a non-fork
10
+ head and `main` as its base. The author, original actor and rerunning actor each
11
+ need `admin`, `maintain` or `write` repository permission. The fixed
12
+ `dependabot[bot]` and `pineforge-app[bot]` exceptions match the existing authz
13
+ policy. A missing identity, failed API lookup, unexpected permission or stale
14
+ event head refuses admission. The original `test.yml` authz job remains hosted
15
+ on push and dispatch and retains its author permission fallback.
16
+
17
+ Before setting `allowed=true`, admission reads the immutable head's recursive
18
+ Git tree, refuses truncation, symlinks, submodules, unsafe names and oversized
19
+ inputs, then runs pinned actionlint with the base configuration and the base
20
+ security rules. Only workflow/action files, the actionlint configuration and
21
+ `package.json` cache metadata are fetched. Directory entries are skipped;
22
+ regular blobs are limited to 100 files, 1 MiB each and 4 MiB total, with decoded
23
+ lengths checked against the tree.
24
+ The scanner bounds lines at 4,096 characters, files at 20,000 lines and
25
+ structure at 40 levels. It refuses ambiguous YAML structure, duplicate keys,
26
+ anchors, aliases, tags, merge keys, dynamic runner expressions, grouped runner
27
+ mappings, unsupported flow values and control characters. Ordinary quoted text,
28
+ GitHub expressions in environment values, and script block contents are kept
29
+ separate from routing structure.
30
+
31
+ Every admitted PR, including a documentation or workflow change, runs the full
32
+ matrix and differential checks. There is no cheap-skip classifier to trust.
33
+ The hosted result requires each prerequisite to succeed, rechecks live PR and
34
+ actor identity, and posts the `gate` status to the immutable event head. A
35
+ failure, skip, cancellation, missing output, stale head or refusal fails the
36
+ result. Status publication failure also fails the job.
37
+
38
+ | Previous PR context | Current context |
39
+ | --- | --- |
40
+ | Test / authz | Test / authz stays on `ubuntu-24.04` for push and dispatch |
41
+ | Test / changes | GKE PR / admit; Test / changes stays on `ubuntu-24.04` for push and dispatch |
42
+ | Test / workflow-lint | Test / workflow-lint uses `gke-8cpu-16gb-amd64` on push and dispatch; GKE PR / workflow-lint checks the candidate |
43
+ | Test / package-files | GKE PR / package-files; Test / package-files uses `gke-8cpu-16gb-amd64` on push and dispatch |
44
+ | Test / pytest (3.11, 3.12, 3.13, 3.14) | GKE PR / pytest, with the same versions; Test / pytest uses `gke-8cpu-16gb-amd64` on push and dispatch |
45
+ | Test / test-check | GKE PR / test-check stays hosted; Test / test-check stays on `ubuntu-24.04` for push and dispatch |
46
+ | Pyodide Gate / preflight-docs | GKE PR / admit |
47
+ | Pyodide Gate / differential | GKE PR / differential |
48
+ | Pyodide Gate / pytest (3.11, 3.12, 3.13, 3.14) | The shared GKE PR / pytest matrix |
49
+ | Pyodide Gate / gate and the `gate` commit status | GKE PR / gate and the same `gate` commit status, hosted |
50
+
51
+ The shared pytest matrix runs the same command as both former PR matrices.
52
+ The differential leg retains Python 3.14, Node 22, the Pyodide selftest,
53
+ dependency audit and full gate. Package metadata and entity checks run on every
54
+ admitted diff, as does the workflow/App-environment guard.
55
+
56
+ All pod jobs use the bare scalar `gke-8cpu-16gb-amd64`. The image supplies the
57
+ engine toolchain, Python 3.12 with venv, git, git-lfs, jq, curl, actionlint,
58
+ shellcheck and gh. Pinned setup actions supply the other Python versions and
59
+ Node/npm 22. The pod jobs have only `contents: read`, persist no checkout
60
+ credentials, receive no secret, OIDC permission or environment, and use no
61
+ Actions cache. Hosted admission has read-only contents permission; only the
62
+ hosted result can write statuses.
63
+
64
+ An Actions runtime/cache token is still available to PR code on a runner.
65
+ Consequently the policy also refuses Actions cache restore/save steps and
66
+ setup cache inputs throughout the workflow/action data it checks: trusted jobs
67
+ must never restore cache entries a PR could write. Differential artifacts are
68
+ diagnostics for that run; the result does not download or trust them.
69
+ Node setup explicitly sets `package-manager-cache: false` in admission and
70
+ the retained gate workflow. The unchanged promotion Node setup is admitted
71
+ only while `package.json` has no `packageManager` or
72
+ `devEngines.packageManager` opt-in. Adding such metadata requires disabling
73
+ that remaining setup default in a separate base change first.
74
+
75
+ `test.yml` has only push-to-main and dispatch triggers: `workflow-lint`,
76
+ `package-files` and `pytest` use `gke-8cpu-16gb-amd64`; `authz`, `changes` and
77
+ `test-check` use `ubuntu-24.04`. Pull-request checks use `gke-pr.yml` admission.
78
+ The existing App-environment guard keeps its authorization dependency and
79
+ blocking step. Workflow lint uses the checked-in actionlint configuration
80
+ and the exact checkout head.
81
+ `gate.yml` retains only its hosted schedule and dispatch
82
+ legs. Those trusted routes require a separate runner admission entry before
83
+ they can move. PyPI/npm publication and baseline promotion remain hosted.
84
+
85
+ The only `pull_request_target` workflow is `gke-pr.yml`.
86
+ `promote-baseline.yml` runs on pushes to `main` and manual dispatch from `main`.
87
+ Manual dispatch validates `merge_commit` and `head_sha` as lowercase 40-hex, `pr_number` as a positive decimal, `pr_url` for this repository and number, and `merged_at` as `YYYY-MM-DDTHH:MM:SSZ`.
88
+ It checks the numbered PR and paginated commit associations with `gh`, requiring one merged PR on `main` whose merge, head, and merge time match the inputs.
89
+ API errors, empty responses, mismatches, and multiple associations refuse dispatch.
90
+ If dispatch refuses, re-read the values from the merged pull request page or
91
+ `gh pr view <n> --json mergeCommit,headRefOid,mergedAt,url`, then dispatch again from `main`.
92
+ Never edit the workflow to get past a refusal.
93
+ Promotion paginates the pushed commit's associated PRs and requires exactly one
94
+ closed, merged PR with that merge commit and base `main`; zero or multiple
95
+ matches skip promotion green. It rereads that PR's full record, binds its gated
96
+ head, merge commit, author, merger, number, URL and merge time, then checks
97
+ authorization and tree equality. Codegen still requires the `gate` context
98
+ to succeed on that head (the trusted reporter's status, else a success
99
+ check-run) and no failing newest check-run per app and name. The hosted runner,
100
+ release environment and WIF workflow-path/main-ref binding remain in place;
101
+ the workflow checks out and runs no PR code.
102
+
103
+ Runner-group and merge-authority configuration are operator work outside this
104
+ repository change. Enable only
105
+ `pineforge-4pass/pineforge-codegen-oss/.github/workflows/gke-pr.yml@refs/heads/main`
106
+ for PR pods; do not enable a caller-controlled reusable workflow or a
107
+ `pull_request` workflow. Update consumers of the context mapping above before
108
+ relying on the new checks. Consumers should bind the workflow run's exact
109
+ path/ref, `pull_request_target` event and
110
+ `gke-pr #<PR number> <40-hex head SHA>` title to the current live PR head, then
111
+ require the newest matching run to conclude `success`. A missing, skipped,
112
+ cancelled or refused run is not success. A push after a live-state read can
113
+ leave only an old-head result; the consumer must recheck the current head.
114
+
115
+ Main's rules judge candidate workflows. A new runner label or a rule relaxation
116
+ therefore needs two changes: first expand the base checker/configuration
117
+ without using the relaxation in a workflow, then change the workflow.
118
+ Tightening a workflow must satisfy the base rules too. Bootstrap this workflow
119
+ on `main` and configure the runner entry before expecting it to run for later
120
+ PRs; its first adoption PR still needs independent CI evidence.
121
+
122
+ The checker and its mutation controls use only Python's standard library plus
123
+ pytest for the tests. File-reading modes list their inputs, refuse credential
124
+ paths and `*.env`, and reject symlinks before opening files. Full tests,
125
+ engine-enabled corpus compilation and the Pyodide gate must run in CI or on
126
+ the designated build box; a source inspection is not an execution verdict.
@@ -5,19 +5,26 @@ from collections.abc import Mapping
5
5
  from .lexer import Lexer
6
6
  from .parser import Parser
7
7
  from .analyzer import Analyzer
8
+ from .analyzer.value_bindings import ValueBindings
8
9
  from .codegen import CodeGen
9
10
  from .cpp_allowlist import REASONS, check_generated_cpp
10
11
  from .diagnostic_codes import diagnostics_catalog, render_diagnostic
11
- from .errors import CompileError, Diagnostic, Level, Phase, SourceLocation
12
+ from .errors import (
13
+ CodegenInvariantError, CompileError, Diagnostic, Level, Phase, SourceLocation,
14
+ )
12
15
  from .external_requests import lower_no_data_requests
13
16
  from .builtin_keywords import bind_builtin_keywords
14
17
  from .finite_ta_length import expand_finite_choice_extrema_lengths
18
+ from .function_overloads import bind_scalar_overloads
15
19
  from .library_inline import inline_libraries
16
20
  from .limits import TimeBudget, check_ast_depth, check_source_size, ensure_recursion_headroom
21
+ from .method_binding import validate_call_argument_order
17
22
  from .pragmas import extract_pf_trace_pragmas
18
23
  from .request_discovery import discover_requests, request_sites
19
24
  from .request_feed_inventory import build_request_feed_inventory
20
- from .security_contexts import specialize_security_contexts
25
+ from .security_contexts import (
26
+ specialize_method_security_payloads, specialize_security_contexts,
27
+ )
21
28
  from .block_locals import rename_block_locals
22
29
  from .support_checker import check_support as _support_diagnostics
23
30
  from .support_checker import check_support_or_raise
@@ -40,6 +47,7 @@ def _parse_bounded(pine_source: str, filename: str, budget: TimeBudget | None =
40
47
  budget=budget).parse()
41
48
  check_ast_depth(ast, filename)
42
49
  budget.check(phase=Phase.PARSER)
50
+ validate_call_argument_order(ast, filename=filename)
43
51
  return ast, pragmas, budget
44
52
 
45
53
 
@@ -69,6 +77,7 @@ def _generate(pine_source: str, check_support: bool, filename: str,
69
77
  ast, pragmas, budget = _parse_bounded(pine_source, filename, budget)
70
78
  ast = inline_libraries(ast, pine_source, libraries=libraries,
71
79
  filename=filename, budget=budget)
80
+ ast = bind_scalar_overloads(ast, budget=budget)
72
81
  rename_block_locals(ast, renamed)
73
82
  support_diagnostics = []
74
83
  if check_support:
@@ -76,6 +85,7 @@ def _generate(pine_source: str, check_support: bool, filename: str,
76
85
  if any(d.level == Level.ERROR for d in support_diagnostics):
77
86
  raise CompileError(support_diagnostics)
78
87
  budget.check(phase=Phase.ANALYZER)
88
+ ValueBindings(ast, filename, budget).resolve()
79
89
  sites = request_sites(ast)
80
90
  ast = lower_no_data_requests(ast)
81
91
  ast = specialize_security_contexts(ast, filename=filename)
@@ -84,14 +94,37 @@ def _generate(pine_source: str, check_support: bool, filename: str,
84
94
  budget.check(phase=Phase.ANALYZER)
85
95
  ctx = Analyzer(ast, filename=filename, budget=budget,
86
96
  session_clones=clones).analyze()
97
+ # Typed receiver dispatch is known only after analysis. Resolve method
98
+ # payload arguments with those bindings, then type the rewritten bodies.
99
+ if specialize_method_security_payloads(
100
+ ast, ctx.method_call_bindings, filename=filename):
101
+ del ctx
102
+ ast = bind_builtin_keywords(expand_finite_choice_extrema_lengths(ast))
103
+ check_ast_depth(ast, filename)
104
+ ctx = Analyzer(ast, filename=filename, budget=budget,
105
+ session_clones=clones).analyze()
87
106
  budget.check(phase=Phase.ANALYZER)
88
107
  # Attach after analysis: pragma expressions are not part of the
89
108
  # program body, so the analyzer never inspects them; the codegen
90
109
  # consumes them directly from the context to emit the on_bar tail
91
110
  # ``if (trace_enabled_) { trace(...); ... }`` block.
92
111
  ctx.pf_trace_pragmas = pragmas
93
- gen = CodeGen(ctx, budget=budget)
94
- cpp = gen.generate()
112
+ try:
113
+ gen = CodeGen(ctx, budget=budget)
114
+ cpp = gen.generate()
115
+ except CodegenInvariantError as error:
116
+ node_kind = error.node_kind
117
+ location = getattr(error.node, "loc", None)
118
+ if location is None:
119
+ raise RuntimeError(
120
+ f"Internal error: AST node '{node_kind}' has no source "
121
+ "location for its missing value lowering."
122
+ ) from error
123
+ raise CompileError([Diagnostic(
124
+ level=Level.ERROR, phase=Phase.CODEGEN, location=location,
125
+ message=f"Internal error: no value lowering for AST node '{node_kind}'.",
126
+ hint="Report this translator error to PineForge.",
127
+ )]) from error
95
128
  budget.check(phase=Phase.CODEGEN)
96
129
  apart = gen.block_locals_needing_names - renamed
97
130
  if apart: