Skip to content

Commit c33724c

Browse files
luisleo526claude
andcommitted
Merge engine main into the security timeframe warning
Engine main took the 1.12.0 release, a CI change and the close quantity step fix. This branch still carries the earlier commits of that fix, while main has it as one squashed commit, so the merge from their common base reports conflicts in the files both touched. Each is resolved to main's version plus this branch's own change; apart from the files named below, the merged tree adds exactly this branch's change to main. - CHANGELOG.md: main's sentence on an invalid mintick and point value, followed by this branch's three entries. - docs/design/native-feature-parity.md, row P8: main's wording, with the line numbers of the merged sources. - docker/run_failure_codes_diff.json: regenerated with scripts/gen_run_failure_catalog_diff.py --write against the 1.12.0 catalog, not merged by hand. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2 parents 23f1cd5 + 2bbdd48 commit c33724c

8 files changed

Lines changed: 64 additions & 92 deletions

File tree

‎.github/workflows/gke-pr.yml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,16 @@ jobs:
339339
cmake --build build --target pineforge_pr_smoke --parallel "$(getconf _NPROCESSORS_ONLN)"
340340
ctest --test-dir build -L '^fast$' --output-on-failure --no-tests=error \
341341
--parallel "$(getconf _NPROCESSORS_ONLN)" --output-junit build/ctest-junit.xml
342+
- name: Retain PR smoke test output
343+
if: always()
344+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
345+
with:
346+
name: pr-smoke-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }}
347+
path: |
348+
build/ctest-junit.xml
349+
build/Testing/Temporary/LastTest.log
350+
retention-days: 3
351+
if-no-files-found: warn
342352

343353
build-debug:
344354
needs: [admit]
@@ -373,6 +383,16 @@ jobs:
373383
cmake --build build --target pineforge_pr_smoke --parallel "$(getconf _NPROCESSORS_ONLN)"
374384
ctest --test-dir build -L '^fast$' --output-on-failure --no-tests=error \
375385
--parallel "$(getconf _NPROCESSORS_ONLN)" --output-junit build/ctest-junit.xml
386+
- name: Retain PR smoke test output
387+
if: always()
388+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
389+
with:
390+
name: pr-smoke-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }}
391+
path: |
392+
build/ctest-junit.xml
393+
build/Testing/Temporary/LastTest.log
394+
retention-days: 3
395+
if-no-files-found: warn
376396

377397
build-arm:
378398
needs: [admit]

‎CHANGELOG.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ version number follows semantic versioning over the surfaces the
1515
- A memory failure during a session-calendar lookup now fails the run with a typed error instead of reading the bar as out of session.
1616
- A failed `setenv` or a memory failure during a timezone switch now fails the run instead of continuing in the previous zone or in UTC.
1717
- A timezone database lookup that fails because no file descriptors or memory are available, an input/output error occurs, or the database is missing now fails the run with an engine error instead of reporting an incorrect timezone name.
18-
- A timezone name written in a script that the engine does not accept now raises `pine_timezone_error` with the function and zone instead of silently reading UTC. This addition to the public failure catalog requires a minor release. The message is TradingView's text with the engine's bar prefix, `Error on bar N: `, or `Error before the first bar: ` when no bar is being executed, and the arguments carry `bar_index`.
18+
- A timezone name written in a script that the engine's own calendar functions do not accept now raises `pine_timezone_error` with the function and zone instead of silently reading UTC. Code that the transpiler generates for `timestamp()` still reads a zone that the host cannot load as UTC, without an error (with a zone argument, and without one on a symbol whose zone is not UTC); that is fixed in a later release. This addition to the public failure catalog requires a minor release. The message is TradingView's text with the engine's bar prefix, `Error on bar N: `, or `Error before the first bar: ` when no bar is being executed, and the arguments carry `bar_index`.
1919
- The void C setters for instrument and run settings now record exceptions on
2020
the handle, including allocation failures and changes refused by the engine.
2121
`strategy_last_run_status` reads 1; `strategy_get_last_error` and
@@ -29,12 +29,12 @@ version number follows semantic versioning over the surfaces the
2929
read through `strategy_state_query_status_v1`.
3030
- Non-positive or NaN `mintick` or `pointvalue` values in `--syminfo`, and
3131
`path_order` modes outside 0, 1 and 2, now produce typed refusals instead of
32-
being ignored or reset to AUTO. Invalid point values use the existing symbol
33-
metadata error.
32+
being ignored or reset to AUTO. An invalid `mintick` is refused as `symbol_feeds_refused` with reason
33+
`syminfo_mintick_invalid`; an invalid point value uses the existing symbol metadata error, `symbol_metadata_rejected` with field `point_value`.
3434
- `strategy_get_run_warnings` exposes one named warning per `request.security` call site whose requested timeframe is not a multiple of its evaluator's feed timeframe; values, trades and run acceptance are unchanged (#718).
3535
- The Docker report and `scripts/run_strategy.py` now show the engine's run warnings as `diagnostics.warnings` when a run has any, and are unchanged otherwise (#718).
3636
- A percent-of-equity default quantity above 100 percent is now capped at 100 percent of equity when `margin_long` and `margin_short` are both 0 (#805).
37-
- `strategy.close(qty = ...)` now floors the quantity to the declared quantity step and closes that much, as TradingView does; a quantity that floors to zero or exceeds the entry id's position closes that whole position. Positive explicit `strategy.exit(qty = ...)` quantities now floor to the declared step; a quantity below one step is ignored, so the exit covers the whole position with the default `qty_percent = 100`, as TradingView does. Measured against TradingView on one instrument and lot (a 0.00001 step, pyramiding 1, the default close rule, one entry id); not measured: `close_entries_rule = "ANY"`, pyramided entry ids, whole-unit steps, lots that are not a power of ten, and a sub-step `strategy.exit` quantity with `qty_percent` below 100 (#716).
37+
- `strategy.close(qty = ...)` now floors the quantity to the declared quantity step and closes that much, as TradingView does; a quantity that floors to zero or exceeds the entry id's position closes that whole position. Positive explicit `strategy.exit(qty = ...)` quantities now floor to the declared step; a quantity below one step is ignored unless `qty_percent` is below 100, so with the default `qty_percent = 100` the exit covers the whole position, as TradingView does; with `qty_percent` below 100 such a quantity is kept as given, as before. Measured against TradingView on one instrument and lot (a 0.00001 step, pyramiding 1, the default close rule, one entry id); not measured: `close_entries_rule = "ANY"`, pyramided entry ids, whole-unit steps, lots that are not a power of ten, and a sub-step `strategy.exit` quantity with `qty_percent` below 100 (#716).
3838
- With `process_orders_on_close` and the default FIFO close rule, the named `strategy.exit` calls of a reversing `strategy.entry` with an explicit quantity, placed in the same execution after a `strategy.close` of the old position, are now sized from the new entry's own quantity: a percentage exit takes its share of the new entry and an absolute-quantity exit keeps its quantity, instead of being sized from a basis reduced by the old position (#803).
3939
- Without `process_orders_on_close`, the named `strategy.exit` calls placed with a reversing `strategy.entry` of explicit quantity now take their percentage from the new entry when its size differs from the position it replaces, and a take-profit given as an absolute quantity now fires; before, the percentage was taken from the position being replaced and an absolute-quantity take-profit never fired (#803).
4040
- `strategy.risk.max_drawdown` is now tested at the order fills that close units, on the equity at that fill with open positions included, against the highest equity at such fills (the equity at an opening fill or at a bar close does not raise it), and a breach closes every open position at that fill's price (exit text "Close Position (Max Drawdown)"), cancels the pending orders and blocks later entries; before, it was measured once per bar close and only refused new entries (#804).

‎VERSION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.11.0
1+
1.12.0

‎docker/run_failure_codes_diff.json‎

Lines changed: 4 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"schema": "pineforge-run-failure-catalog-diff/v1",
33
"from": {
4-
"version": "1.11.0",
5-
"tag": "v1.11.0",
6-
"catalogSha256": "7e903f977be655901c877a3550008aeee19b7f69a9ecfad986ca6f0d9129c3be"
4+
"version": "1.12.0",
5+
"tag": "v1.12.0",
6+
"catalogSha256": "c42c7305aee58908b46b98768480d23f8346e1d010cfc32b6f83d594950408b4"
77
},
88
"to": {
99
"version": null,
@@ -15,83 +15,8 @@
1515
"after": "pineforge-run-failure-catalog/v1"
1616
},
1717
"metadataChanges": [],
18-
"added": [
19-
{
20-
"code": "pine_timezone_error",
21-
"collection": "codes",
22-
"entry": {
23-
"args": {
24-
"bar_index": {
25-
"kind": "integer"
26-
},
27-
"function": {
28-
"kind": "vocab",
29-
"values": [
30-
"time",
31-
"time_close",
32-
"timestamp",
33-
"hour",
34-
"minute",
35-
"second",
36-
"dayofmonth",
37-
"dayofweek",
38-
"month",
39-
"year",
40-
"weekofyear",
41-
"format_time"
42-
]
43-
},
44-
"zone": {
45-
"kind": "string"
46-
}
47-
},
48-
"class": "strategy",
49-
"description": "A timezone argument is not accepted by the calendar. TradingView runtime error RE10133. bar_index is the bar being executed, and -1 when the stop is raised before the first bar (the message then begins \"Error before the first bar: \" instead of \"Error on bar N: \").",
50-
"english": [
51-
"Error on bar {bar_index}: Incorrect `timezone` value for the {function}() function: \"{zone}\". The value must be a string in either UTC/GMT notation (e.g. \"UTC-5\", \"GMT+0530\") or an IANA time zone database name (e.g. \"America/New_York\")."
52-
],
53-
"retryable": false,
54-
"since": "1.12.0"
55-
}
56-
}
57-
],
18+
"added": [],
5819
"changed": [
59-
{
60-
"code": "pine_string_error",
61-
"collection": "codes",
62-
"fields": [
63-
{
64-
"path": "args.reason.values",
65-
"beforePresent": true,
66-
"afterPresent": true,
67-
"before": [
68-
"substring_out_of_range",
69-
"format_index_overflow"
70-
],
71-
"after": [
72-
"substring_out_of_range",
73-
"format_index_overflow",
74-
"invalid_regex_pattern",
75-
"regex_resource_limit"
76-
]
77-
},
78-
{
79-
"path": "english",
80-
"beforePresent": true,
81-
"afterPresent": true,
82-
"before": [
83-
"basic_string::substr: __pos (which is {pos}) > this->size() (which is {size})",
84-
"stoul"
85-
],
86-
"after": [
87-
"basic_string::substr: __pos (which is {pos}) > this->size() (which is {size})",
88-
"stoul",
89-
"Invalid regex pattern in the 'str.match' function.",
90-
"A regular expression exceeds the limits of the engine's regular-expression library."
91-
]
92-
}
93-
]
94-
},
9520
{
9621
"code": "run_options_rejected",
9722
"collection": "codes",

‎docs/design/native-feature-parity.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1671,7 +1671,7 @@ the rule gives 9.9 + 9.89).
16711671
| P5 | **Test asymmetry:** 430 adapter test files vs 14 native when this plan was written (on this tree 486 `tests/*.cpp` name `source::PineStrategyHost`, 128 `NativeStrategyHost`) | native-only tests in every lane (§3.1 b) | O |
16721672
| P6 | **Stream vs batch.** The stream refuses monthly input, mixed modes, in-session gaps, security feeds and source setters, and tick input under an FX curve (any non-empty curve until the FX stream audit) (`native-engine.md`, "Stream limitations (current)") | L5 and L6 must state which refusals are generic and which are deliberate source limits | S |
16731673
| P7 | **C ABI variant growth** | §2.iii hardening rules | S |
1674-
| P8 | **Unverified in the inputs:** whether `execution::LifecycleEffects` (execution.hpp:136-139) is ever non-empty from the Pine path, else `PlacementSnapshot::legs` (pine_adapter.hpp:385) is the only live lifecycle (O); the `strategy.risk.allow_entry_in` setter chain beyond `set_pine_risk_direction` pine_strategy_host.cpp:1245 → `set_risk_direction` pine_adapter.cpp:27365 (O); what the ABI receipts pin (F); the probe corpus itself lives outside this tree (F) | verify inside the lane that touches each | F O |
1674+
| P8 | **Unverified in the inputs:** whether `execution::LifecycleEffects` (execution.hpp:136-139) is ever non-empty from the Pine path, else `PlacementSnapshot::legs` (pine_adapter.hpp:385) is the only live lifecycle (O); the `strategy.risk.allow_entry_in` setter chain beyond `set_pine_risk_direction` pine_strategy_host.cpp:1245 → `set_risk_direction` pine_adapter.cpp:27365 (O); what the ABI receipts pin (F); the probe corpus itself lives outside this tree (F) | verify inside the work item that touches each | F O |
16751675
16761676
### 4.3 Open design questions (supervisor level)
16771677

‎docs/pages/pine-to-native.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ source-only features state why a native counterpart does not exist.
192192
| SZ9 | Mapped by the migration table above. |
193193
| SZ10 | No separate native counterpart: Pine money rounding is an adapter policy over the native sizing basis. |
194194
| SZ10a | No separate native counterpart: the money band's affordable price is TradingView's ten-significant-digit whole-drop price, adapter policy measured on the famr / famr3 tapes; every money-to-units conversion the adapter makes is the kernel's `native_sized_units`. |
195-
| SZ11 | No separate native counterpart: Pine quantity floors are adapter policy; native `quantity_grid` is the generic knob. With a declared quantity step, a positive finite `strategy.close(qty = ...)` quantity is floored to that step; a quantity that floors to zero or exceeds the entry id's position closes that whole position. Positive explicit `strategy.exit(qty = ...)` quantities also floor to that step; a quantity below one step is ignored, so the exit covers the whole position with the default `qty_percent = 100`, as TradingView does. Measured on a 0.00001 step with pyramiding 1, the default close rule and one entry id; `close_entries_rule = "ANY"`, pyramided entry ids, whole-unit steps, lots that are not a power of ten and a sub-step exit quantity with `qty_percent` below 100 are not measured. |
195+
| SZ11 | No separate native counterpart: Pine quantity floors are adapter policy; native `quantity_grid` is the generic knob. With a declared quantity step, a positive finite `strategy.close(qty = ...)` quantity is floored to that step; a quantity that floors to zero or exceeds the entry id's position closes that whole position. Positive explicit `strategy.exit(qty = ...)` quantities also floor to that step; a quantity below one step is ignored unless `qty_percent` is below 100, so with the default `qty_percent = 100` the exit covers the whole position, as TradingView does; with `qty_percent` below 100 such a quantity is kept as given. Measured on a 0.00001 step with pyramiding 1, the default close rule and one entry id; `close_entries_rule = "ANY"`, pyramided entry ids, whole-unit steps, lots that are not a power of ten and a sub-step exit quantity with `qty_percent` below 100 are not measured. |
196196
| SZ12 | No separate native counterpart: Pine reservation ledger details stay in the adapter over native scope claims. |
197197
| MG1 | Mapped by the migration table above. |
198198
| MG2 | Mapped by the migration table above. |

‎scripts/test_ci_preflight.py‎

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13282,6 +13282,7 @@ class GkeSmokeOutputAdmission(unittest.TestCase):
1328213282
'''
1328313283
LAYOUT = 'gke-pr.yml {} must retain exactly its four smoke steps and optional pinned final output collector'
1328413284
COLLECTOR_FINDING = 'gke-pr.yml {} must retain the pinned always-upload PR smoke output collector'
13285+
SHIPPED_RETENTION = 'gke-pr.yml {} must ship the pinned final PR smoke output collector'
1328513286

1328613287
def setUp(self):
1328713288
path = ROOT / '.github/workflows/gke-pr.yml'
@@ -13306,6 +13307,24 @@ def assert_refused(self, changed, finding):
1330613307
self.assertIn(finding, gke_admit_workflow_findings(changed))
1330713308
self.assertIn(finding, main_admission_data_findings({'gke-pr.yml': changed}))
1330813309

13310+
def assert_shipped_retention(self, workflow):
13311+
"""Pin the shipped collectors while admission still accepts four steps."""
13312+
jobs = _jobs(workflow)
13313+
for job in ('build', 'build-debug'):
13314+
steps = ci_preflight._steps(jobs.get(job, ''))
13315+
finding = self.SHIPPED_RETENTION.format(job)
13316+
self.assertEqual(len(steps), 5, finding)
13317+
self.assertEqual(steps[-1].rstrip('\n'), self.COLLECTOR.rstrip('\n'), finding)
13318+
13319+
def test_shipped_workflow_retains_both_final_collectors(self):
13320+
self.assert_shipped_retention(self.shipped)
13321+
for job in ('build', 'build-debug'):
13322+
with self.subTest(missing_collector=job):
13323+
changed = in_job(self.shipped, job, self.COLLECTOR.rstrip('\n'), '')
13324+
self.assertNotEqual(changed, self.shipped)
13325+
with self.assertRaisesRegex(AssertionError, re.escape(self.SHIPPED_RETENTION.format(job))):
13326+
self.assert_shipped_retention(changed)
13327+
1330913328
def test_exact_four_or_five_steps_are_admitted_independently_in_both_jobs(self):
1331013329
self.assertEqual(gke_admit_workflow_findings(self.shipped), [])
1331113330
self.assertEqual(main_admission_data_findings({'gke-pr.yml': self.shipped}), [])
@@ -13316,7 +13335,8 @@ def test_exact_four_or_five_steps_are_admitted_independently_in_both_jobs(self):
1331613335
self.assertEqual(main_admission_data_findings({'gke-pr.yml': workflow}), [])
1331713336

1331813337
def test_each_collector_field_and_extra_execution_key_is_binding(self):
13319-
workflow = self.with_collectors()
13338+
workflow = self.shipped
13339+
self.assert_shipped_retention(workflow)
1332013340
for job in ('build', 'build-debug'):
1332113341
for before, after in (
1332213342
('Retain PR smoke test output', 'Upload logs'),
@@ -13340,10 +13360,13 @@ def test_each_collector_field_and_extra_execution_key_is_binding(self):
1334013360
collector = self.COLLECTOR.rstrip('\n')
1334113361
changed = in_job(workflow, job, collector, collector.replace(before, after, 1))
1334213362
self.assertNotEqual(changed, workflow)
13363+
with self.assertRaisesRegex(AssertionError, re.escape(self.SHIPPED_RETENTION.format(job))):
13364+
self.assert_shipped_retention(changed)
1334313365
self.assert_refused(changed, self.COLLECTOR_FINDING.format(job))
1334413366

1334513367
def test_collector_position_extra_steps_and_missing_producers_are_refused(self):
13346-
workflow = self.with_collectors()
13368+
workflow = self.shipped
13369+
self.assert_shipped_retention(workflow)
1334713370
for job in ('build', 'build-debug'):
1334813371
old_steps = ci_preflight._steps(_jobs(self.original)[job])
1334913372
for step in old_steps:
@@ -13361,7 +13384,11 @@ def test_collector_position_extra_steps_and_missing_producers_are_refused(self):
1336113384
with self.subTest(job=job, collector_position=position):
1336213385
moved = body.replace(collector, '', 1)
1336313386
moved = moved.replace(steps[position], collector + '\n' + steps[position], 1)
13364-
self.assert_refused(in_job(workflow, job, body, moved), self.LAYOUT.format(job))
13387+
changed = in_job(workflow, job, body, moved)
13388+
self.assertNotEqual(changed, workflow)
13389+
with self.assertRaisesRegex(AssertionError, re.escape(self.SHIPPED_RETENTION.format(job))):
13390+
self.assert_shipped_retention(changed)
13391+
self.assert_refused(changed, self.LAYOUT.format(job))
1336513392
for before, after in (
1336613393
(collector, collector + '\n' + collector),
1336713394
(collector, collector + '\n - run: true'),

0 commit comments

Comments
 (0)