Repository navigation
Commit e163980
Fail the run on an unaccepted timezone or a failed void setter (#837)
The scoped-timezone mechanism ignored the result of setenv, and a
memory failure while a zone was switched left the caller in the previous
zone or in UTC. A zone name written in a script reached setenv and tzset
unchecked in three families (the time fields hour to weekofyear, time()
and time_close() with the session predicates, and str.format_time), and
an unknown name such as "America/Newyork" silently read as UTC, where
TradingView stops the run. The fourteen void C setters for the
instrument and run settings swallowed every exception, whether an
allocation failure or a change the engine refused, so a run could start
with a setting that was never applied and finish with a wrong result.
An unaccepted timezone name now stops the run with the new code
pine_timezone_error (class strategy, not retryable, since 1.12.0). Its
arguments are bar_index, function and zone. The message is TradingView's
text (runtime error RE10133) with the engine's bar prefix, "Error on bar
N: ", or "Error before the first bar: " when no bar is being executed.
The prefix comes from the one function that already builds it for the
regular-expression stop, run_error_bar_prefix; a second function,
run_error_bar_index, supplies the argument (-1 when no bar is being
executed). Generated code reaches the stop through
pine_timezone_stop(function, zone, english), offered under its own macro,
PINEFORGE_HAS_TIMEZONE_STOP_V1; the caller passes the English without a
prefix. TradingView's function name is captured for time and timestamp
only: the other ten names of the vocabulary are the engine's choice, and
the session predicates report time although their zone is the symbol's.
Accepted names are remembered in a table of eight slots per thread, so a
repeated name is not checked again. A failed setenv (out_of_memory for
ENOMEM, engine_unclassified_error with the errno kept for any other
error) and a memory failure while the timezone is switched now fail the
run.
The void C setters now record every exception on the handle:
strategy_last_run_status reads 1, and strategy_get_last_error and
strategy_get_last_error_code return the text and the code. The text
begins with the same bar prefix. A setup failure makes the next run
start fail once with that record; the following start clears it and
starts normally. The failed setter did not apply its value, so a retry of
the start without applying the setter again runs on the previous value.
The documented refusal of a quote write after a selected run has sealed
is unchanged: it is still dropped silently and read through
strategy_state_query_status_v1. Non-positive or NaN mintick and
pointvalue in a --syminfo document, and path_order modes outside 0, 1 and
2, now give typed refusals (the existing symbol metadata error for the
tick and the point value, setting_rejected for the mode) instead of being
ignored or reset to AUTO.
The new tests use a counting replacement of the global operator new
(tests/fail_alloc_seam.hpp) to refuse each allocation of a run in turn:
every allocation must end in a typed failure or in a closed-trade list
(and its totals) identical to the clean run, never in a different
completed result, and the sweeps print the indexes at which a run
completed. The setenv failure is injected by an interposer in the test,
with no hook in the production code. One test covers the timezone name
check and the zone switch, one the setter paths, and a Python test reads
the --syminfo refusals.
The new code is also registered where codes are counted and announced:
tests/test_run_failure_code_numbers.py pins its number (88) and the
enumerator count (89), the page docs/pages/run-failure-codes.md counts 88
named codes and 89 registry entries and names the code in its preamble,
and the registry count pinned in tests/test_run_failure_codes.cpp becomes
89.
Documentation sentences this change removes or rewrites:
- docs/pages/run-failure-codes.md, the preamble: "The catalog contains 87
named failure codes: 38 first released in 1.4.0, 26 first released in
1.5.0, 5 added in 1.7.0, 10 added in 1.9.0 (3 run-quota codes and 7
report-channel codes), and 8 added in 1.11.0." and "One unnamed `none`
sentinel gives 88 registry entries; existing numbers stay fixed." They
now count 88 named codes (one added in 1.12.0) and 89 registry entries.
- docs/pages/live-surface.md: "Any other `mode` is clamped to AUTO."
An out-of-range path_order mode now records a typed setting_rejected
error.
- docs/adr/0001-kernel-adapter-boundary.md, the row of
strategy_set_path_order: "clamps an out-of-range mode to AUTO" and "A
`void` ABI v4 setter cannot answer a refusal." The setter now refuses
and records setting_rejected, readable through strategy_get_last_error,
strategy_get_last_error_code and strategy_last_run_status; the void
signature is unchanged.
- docs/coverage.md, the pine_str_format_time row: "Empty / `"UTC"` /
`"Etc/UTC"` use `gmtime_r`; everything else swaps `TZ` under
`tz_util::ScopedTimezone` and uses `localtime_r`." It now says "other
accepted names" and describes the new error.
- docs/pages/run-failure-codes.md: "hardwires its code and takes only
literals the transpiler emits"; pine_timezone_stop takes the zone
string the script computed.
- docs/adr/0001-kernel-adapter-boundary.md, the row of run-failure code
names: the sentence "Each name states the failure in the terms of the
script that caused it" gains the timezone argument.
ADR-0001 lists pine_timezone_error with the other code names and gives
pine_timezone_stop its own row, because the kernel calls it. The
ownership manifest lists the new code. The catalog gains the code, so a
release that carries this change is a minor one. The allocation-bound
manifest lists three new groups (the number-to-text temporaries of the
setter refusal messages, and the message string of the timezone refusal
with its temporary; ceiling 1415 -> 1418, pinned count 1599 -> 1602) and
its site inventory is re-emitted, and the allowlist of uncoded rethrows
counts the two new rethrows. The lines added to the sources move the
lines the documentation cites below them; the anchors that follow them
are re-pointed by the number of lines added (digits only). Five
pre-existing sentences of docs/adr/0001-kernel-adapter-boundary.md (two)
and docs/design/native-feature-parity.md (three) are also reworded,
because the re-pointed lines count as added lines and the older wording
named an internal work stream by a word that public text does not use;
they now say "work item" and mean the same.
Co-authored-by: Claude Fable 5.2 <[email protected]>1 parent cdb8ae8 commit e163980
49 files changed
Lines changed: 3060 additions & 660 deletions
File tree
- ci
- docker
- docs
- adr
- design
- pages
- include/pineforge
- source
- scripts
- src
- source
- tests
- cr150.d
- ownership
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
15 | 32 | | |
16 | 33 | | |
17 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
107 | 111 | | |
108 | 112 | | |
109 | 113 | | |
| |||
228 | 232 | | |
229 | 233 | | |
230 | 234 | | |
| 235 | + | |
231 | 236 | | |
232 | 237 | | |
233 | 238 | | |
| |||
1279 | 1284 | | |
1280 | 1285 | | |
1281 | 1286 | | |
| 1287 | + | |
1282 | 1288 | | |
| 1289 | + | |
1283 | 1290 | | |
1284 | 1291 | | |
1285 | 1292 | | |
| |||
0 commit comments