Repository navigation
Commit 95f4fd1
authored
C ABI: strategy_initial_capital, so the report writer names simple_proportional_overflow in every run (#565)
## What
Adds the C ABI export `double strategy_initial_capital(pf_strategy_t)`, so the report writer can name `simple_proportional_overflow` exactly, in every run.
Before, `docker/run_json.py` named that reason in `diagnostics.annualization` only when it could prove the first curve mark was the initial capital (the selected-window anchor, or an ordinary run whose first mark had no open profit and no trade entered at bar 0). In every other run of one day or more whose compounded `cagr` was not finite, the reported `cagr` was the simple proportional value the kernel computed, but the reason was silently absent. The revision-3.1 note said a later release could close the gap by reading the capital from the engine; this is that release.
- `strategy_initial_capital` returns the capital the configured run uses: the staged native specification before a run begins, the engine's stored capital otherwise. It returns NaN for a null handle (the same sentinel as `strategy_current_equity`) and adds no kernel state.
- `docker/run_json.py` reads it once per run behind a missing-symbol guard and uses it as the initial capital when it is finite and positive. A library without the export keeps the earlier behaviour byte for byte. The subday branch, every existing absence, the overflow handling and the simple `cagr` value are unchanged.
- The export appears in every list that pins the runtime symbols: the checker's names and counts (113 to 114 declarations, 93 to 94 runtime implementations), the pinned counts in the export-list test and in the docs, and the kernel residual table of the boundary ADR. The frozen legacy export list stays as it is.
- The comment in `src/engine_metrics.cpp` that described the one-day-boundary ranking inversion backwards now says what the documentation says (compounded above simple); no code in that file changed.
- Documentation: the report schema and the revision-3.1 page describe the exact behaviour and the retained gap for older libraries; the C ABI pages and README counts follow.
## Verification
- Red first: with the export present and `docker/run_json.py` at base, the new end-to-end test `test_initial_capital_export_closes_the_unproven_overflow_gap` fails (the reason is absent); on the base tree the new C test and checker lists fail to build and check for the missing export.
- A first lab run found one real defect, fixed here: right after `strategy_configure_native_v1` the first accessor returned the engine's member default, because the native route only stages the specification and copies the capital at the start of the run. The accessor now reads the staged specification; the C test asserts it for a reused host as well.
- All eight lab legs (preflight, release, debug, sanitizers, kernel, docs, parity, subset) pass on the pre-merge head; release and debug pass again on the head merged with main. The edit moved nine citations of the report-sink page; they were re-pointed, and the doc-anchors stage of the preflight on the final head holds them.
- The corpus parity leg and the subset leg report no change in report bytes.
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 parent c85a40b commit 95f4fd1
27 files changed
Lines changed: 292 additions & 136 deletions
File tree
- docker
- docs
- adr
- design
- pages
- include/pineforge
- scripts
- src
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
540 | 540 | | |
541 | 541 | | |
542 | 542 | | |
543 | | - | |
544 | | - | |
545 | | - | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
546 | 546 | | |
547 | | - | |
| 547 | + | |
548 | 548 | | |
549 | 549 | | |
550 | 550 | | |
| |||
589 | 589 | | |
590 | 590 | | |
591 | 591 | | |
| 592 | + | |
592 | 593 | | |
593 | 594 | | |
594 | 595 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3979 | 3979 | | |
3980 | 3980 | | |
3981 | 3981 | | |
3982 | | - | |
| 3982 | + | |
| 3983 | + | |
3983 | 3984 | | |
3984 | 3985 | | |
3985 | 3986 | | |
3986 | 3987 | | |
3987 | 3988 | | |
3988 | 3989 | | |
3989 | 3990 | | |
3990 | | - | |
3991 | | - | |
3992 | | - | |
3993 | | - | |
3994 | | - | |
3995 | | - | |
3996 | | - | |
3997 | | - | |
| 3991 | + | |
| 3992 | + | |
| 3993 | + | |
| 3994 | + | |
| 3995 | + | |
| 3996 | + | |
| 3997 | + | |
| 3998 | + | |
| 3999 | + | |
| 4000 | + | |
| 4001 | + | |
3998 | 4002 | | |
3999 | 4003 | | |
4000 | 4004 | | |
| |||
4008 | 4012 | | |
4009 | 4013 | | |
4010 | 4014 | | |
4011 | | - | |
4012 | | - | |
4013 | | - | |
4014 | | - | |
| 4015 | + | |
| 4016 | + | |
| 4017 | + | |
| 4018 | + | |
| 4019 | + | |
| 4020 | + | |
| 4021 | + | |
| 4022 | + | |
| 4023 | + | |
| 4024 | + | |
| 4025 | + | |
| 4026 | + | |
4015 | 4027 | | |
4016 | 4028 | | |
4017 | 4029 | | |
| |||
4027 | 4039 | | |
4028 | 4040 | | |
4029 | 4041 | | |
4030 | | - | |
| 4042 | + | |
| 4043 | + | |
4031 | 4044 | | |
4032 | | - | |
| 4045 | + | |
| 4046 | + | |
4033 | 4047 | | |
4034 | 4048 | | |
4035 | 4049 | | |
| |||
4055 | 4069 | | |
4056 | 4070 | | |
4057 | 4071 | | |
4058 | | - | |
4059 | | - | |
4060 | | - | |
| 4072 | + | |
| 4073 | + | |
| 4074 | + | |
| 4075 | + | |
4061 | 4076 | | |
4062 | 4077 | | |
4063 | 4078 | | |
| |||
4165 | 4180 | | |
4166 | 4181 | | |
4167 | 4182 | | |
4168 | | - | |
| 4183 | + | |
| 4184 | + | |
4169 | 4185 | | |
4170 | 4186 | | |
4171 | 4187 | | |
| |||
4950 | 4966 | | |
4951 | 4967 | | |
4952 | 4968 | | |
| 4969 | + | |
4953 | 4970 | | |
4954 | 4971 | | |
4955 | 4972 | | |
4956 | 4973 | | |
4957 | 4974 | | |
4958 | | - | |
| 4975 | + | |
4959 | 4976 | | |
4960 | 4977 | | |
4961 | 4978 | | |
| |||
5544 | 5561 | | |
5545 | 5562 | | |
5546 | 5563 | | |
| 5564 | + | |
5547 | 5565 | | |
5548 | 5566 | | |
5549 | 5567 | | |
5550 | 5568 | | |
5551 | | - | |
| 5569 | + | |
| 5570 | + | |
5552 | 5571 | | |
5553 | 5572 | | |
5554 | 5573 | | |
| |||
7101 | 7120 | | |
7102 | 7121 | | |
7103 | 7122 | | |
7104 | | - | |
| 7123 | + | |
7105 | 7124 | | |
7106 | 7125 | | |
7107 | 7126 | | |
7108 | 7127 | | |
7109 | 7128 | | |
7110 | 7129 | | |
7111 | | - | |
| 7130 | + | |
| 7131 | + | |
7112 | 7132 | | |
7113 | 7133 | | |
7114 | 7134 | | |
| |||
7120 | 7140 | | |
7121 | 7141 | | |
7122 | 7142 | | |
7123 | | - | |
| 7143 | + | |
| 7144 | + | |
7124 | 7145 | | |
7125 | 7146 | | |
7126 | 7147 | | |
| |||
7148 | 7169 | | |
7149 | 7170 | | |
7150 | 7171 | | |
7151 | | - | |
| 7172 | + | |
| 7173 | + | |
7152 | 7174 | | |
7153 | 7175 | | |
7154 | 7176 | | |
| |||
7334 | 7356 | | |
7335 | 7357 | | |
7336 | 7358 | | |
| 7359 | + | |
| 7360 | + | |
| 7361 | + | |
| 7362 | + | |
| 7363 | + | |
| 7364 | + | |
| 7365 | + | |
| 7366 | + | |
| 7367 | + | |
7337 | 7368 | | |
7338 | 7369 | | |
7339 | 7370 | | |
| |||
0 commit comments