create-tradejs 3.1.22 → 3.1.23

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 (40) hide show
  1. package/README.md +19 -3
  2. package/dist/index.js +36 -5
  3. package/dist/skill-bundle/.codex/skills/ai-train-local-research/SKILL.md +596 -0
  4. package/dist/skill-bundle/.codex/skills/ai-train-local-research/references/gate-ablation.md +324 -0
  5. package/dist/skill-bundle/.codex/skills/ai-train-local-research/references/reporting.md +227 -0
  6. package/dist/skill-bundle/.codex/skills/ai-train-local-research/scripts/ai-gate-ablation.mjs +5082 -0
  7. package/dist/skill-bundle/.codex/skills/ai-train-local-research/scripts/ai-gate-ablation.test.mjs +1170 -0
  8. package/dist/skill-bundle/.codex/skills/backtest-config-redis/SKILL.md +17 -0
  9. package/dist/skill-bundle/.codex/skills/backtest-config-redis/scripts/get_backtest_config.sh +21 -0
  10. package/dist/skill-bundle/.codex/skills/runtime-parity-mismatch-analysis/SKILL.md +146 -0
  11. package/dist/skill-bundle/.codex/skills/save-strategy-config-from-backtest/SKILL.md +58 -0
  12. package/dist/skill-bundle/.codex/skills/save-strategy-config-from-backtest/agents/openai.yaml +4 -0
  13. package/dist/skill-bundle/.codex/skills/strategy-backtest-research/SKILL.md +334 -0
  14. package/dist/skill-bundle/.codex/skills/strategy-backtest-research/references/research-notes.md +247 -0
  15. package/dist/skill-bundle/.codex/skills/strategy-backtest-research/scripts/backtest-run-metrics.mjs +647 -0
  16. package/dist/skill-bundle/.codex/skills/strategy-backtest-research/scripts/backtest-run-metrics.test.mjs +321 -0
  17. package/dist/skill-bundle/.codex/skills/strategy-backtest-research/scripts/fast-ai-export-metrics.mjs +744 -0
  18. package/dist/skill-bundle/.codex/skills/strategy-backtest-research/scripts/fast-ai-export-metrics.test.mjs +553 -0
  19. package/dist/skill-bundle/.codex/skills/strategy-backtest-research/scripts/research-notes-check.mjs +125 -0
  20. package/dist/skill-bundle/.codex/skills/strategy-improvement-research/SKILL.md +18 -1
  21. package/dist/skill-bundle/.codex/skills/strategy-release/SKILL.md +22 -0
  22. package/dist/skill-bundle/.codex/skills/strategy-release/agents/openai.yaml +4 -0
  23. package/dist/skill-bundle/.codex/skills/strategy-release/references/diagnose-live.md +126 -0
  24. package/dist/skill-bundle/.codex/skills/strategy-release/references/direction-policy.md +141 -0
  25. package/dist/skill-bundle/.codex/skills/strategy-release/references/directional-parameter-split.md +93 -0
  26. package/dist/skill-bundle/.codex/skills/strategy-release/references/evidence-limitations.md +76 -0
  27. package/dist/skill-bundle/.codex/skills/strategy-release/references/evidence-retention.md +157 -0
  28. package/dist/skill-bundle/.codex/skills/strategy-release/references/historical-hypothesis-audit.md +163 -0
  29. package/dist/skill-bundle/.codex/skills/strategy-release/references/professional-research-loop.md +198 -0
  30. package/dist/skill-bundle/.codex/skills/strategy-release/references/release-workflow.md +755 -0
  31. package/dist/skill-bundle/.codex/skills/strategy-release/references/research-objective.md +255 -0
  32. package/dist/skill-bundle/.codex/skills/strategy-release/references/verdict-contract.md +200 -0
  33. package/dist/skill-bundle/.codex/skills/strategy-release/scripts/direction-policy-checkpoint.mjs +137 -0
  34. package/dist/skill-bundle/.codex/skills/strategy-release/scripts/direction-policy-checkpoint.test.mjs +85 -0
  35. package/dist/skill-bundle/.codex/skills/strategy-release/scripts/directional-parameter-checkpoint.mjs +149 -0
  36. package/dist/skill-bundle/.codex/skills/strategy-release/scripts/directional-parameter-checkpoint.test.mjs +120 -0
  37. package/dist/skill-bundle/.codex/skills/strategy-release/scripts/release-progress-checkpoint.mjs +621 -0
  38. package/dist/skill-bundle/.codex/skills/strategy-release/scripts/release-progress-checkpoint.test.mjs +349 -0
  39. package/dist/skill-bundle/.codex/tradejs-skill-bundle.json +44 -3
  40. package/package.json +1 -1
@@ -41,6 +41,18 @@ core/gate/tests, and commit the selected source candidate locally. Do not push,
41
41
  publish packages, edit the Project’s production composition, deploy, start a
42
42
  forward test, or change live risk. Those belong to `$strategy-forward-start`.
43
43
 
44
+ ## Orchestration boundary
45
+
46
+ This skill owns the complete improvement lineage: prior-candidate inventory,
47
+ hypothesis-family choice, trial budget, parent/child decisions, candidate
48
+ selection, and final handoff. Delegate each preregistered core implementation
49
+ and backtest to `$strategy-backtest-research`; that skill returns reconciled
50
+ experiment evidence and does not choose the next candidate. After freezing the
51
+ core finalist/export, delegate deterministic-gate analysis to
52
+ `$ai-train-local-research`; it must not reopen core selection. Read those
53
+ specialist skills when their stage begins instead of duplicating their command,
54
+ metric, or reporting contracts here.
55
+
44
56
  ## Required contour
45
57
 
46
58
  1. Start a new immutable research lineage. Freeze data bounds, point-in-time
@@ -56,6 +68,8 @@ forward test, or change live risk. Those belong to `$strategy-forward-start`.
56
68
  with evidence-driven children and use remaining slots for direction-policy
57
69
  or Pareto rescue. The default cap is 12 genuinely new behaviors. An audit,
58
70
  parser fix, no-op, or rescoring of an old behavior does not consume a slot.
71
+ Execute each frozen experiment through `$strategy-backtest-research` and
72
+ consume its verified result as evidence for the next orchestration decision.
59
73
  5. Do not stop at the audit, baseline, first failed round, or a sparse recent
60
74
  tail. Stop only when a reproducible best candidate is frozen, the fresh
61
75
  budget is exhausted, or every remaining family has a recorded hard causal
@@ -63,7 +77,10 @@ forward test, or change live risk. Those belong to `$strategy-forward-start`.
63
77
  6. Keep one chronological tail sealed during discovery when coverage permits.
64
78
  Open it once for the final selected behavior. Track all exposed tests for
65
79
  multiple-testing/deflated-Sharpe interpretation.
66
- 7. Run package formatting, typecheck, tests, and build in the lineage worktree.
80
+ 7. Freeze the selected core/export before opening deterministic-gate research.
81
+ Run the gate stage through `$ai-train-local-research`; do not retune or
82
+ relabel the raw-core result inside gate tooling.
83
+ 8. Run package formatting, typecheck, tests, and build in the lineage worktree.
67
84
  Commit only the selected candidate and its tests on that worktree branch;
68
85
  preserve rejected experiments as immutable evidence, not source clutter.
69
86
 
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: strategy-release
3
+ description: Deprecated compatibility entrypoint for the former monolithic TradeJS strategy workflow. Use a focused strategy-candidate, strategy-improvement, strategy-period, strategy-forward, or strategy-risk skill instead.
4
+ ---
5
+
6
+ # Strategy Release (Deprecated)
7
+
8
+ Do not run the former all-in-one research and production contour. Route the
9
+ request to exactly one focused skill:
10
+
11
+ - latest selected metrics: `$strategy-candidate-report`;
12
+ - candidate versus production: `$strategy-candidate-compare`;
13
+ - improvement analysis only: `$strategy-improvement-plan`;
14
+ - new core + deterministic-gate research: `$strategy-improvement-research`;
15
+ - frozen candidates on a new period: `$strategy-period-revalidate`;
16
+ - start or replace a risk-1 forward test: `$strategy-forward-start`;
17
+ - inspect a running forward test: `$strategy-forward-status`;
18
+ - increase only `MAX_LOSS_VALUE`: `$strategy-risk-scale`.
19
+
20
+ Never combine research, candidate selection, publication, deployment, and risk
21
+ scaling merely because this legacy name was invoked. Ask for the intended
22
+ focused action only when it cannot be inferred from the user’s wording.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Strategy Release (Deprecated)"
3
+ short_description: "Deprecated compatibility router"
4
+ default_prompt: "Use $strategy-release only as a compatibility router to the single focused TradeJS strategy skill that matches the requested action."
@@ -0,0 +1,126 @@
1
+ # Diagnose live behavior
2
+
3
+ Use this mode to classify observed live behavior of an already released core
4
+ plus deterministic gate composition. Do not tune or release a replacement in
5
+ the same lineage.
6
+
7
+ ## 1. Bind the exact released composition
8
+
9
+ Load the immutable release record and verify:
10
+
11
+ - core config snapshot and fingerprint;
12
+ - deterministic gate fingerprint and `MIN_AI_QUALITY`;
13
+ - runtime mode, strategy code/git SHA, connector, interval, and ticker scope;
14
+ - fees, slippage, entry delay, risk settings, and context-provider settings;
15
+ - release acceptance bounds, terminal windows, and forward-incubation cutoff.
16
+
17
+ Require the runtime artifact to embed deployment snapshot schema v2. Every
18
+ scoped evaluation, signal, trade, and persisted scope must carry runtime lineage
19
+ schema v3 matching the embedded deployment/account, strategy revision,
20
+ strategy package version, complete dependency versions, and runtime package
21
+ version. Track `MAX_LOSS_VALUE` separately: different values are allowed,
22
+ produce immutable `L` evidence, and require all monetary observations to be
23
+ normalized by `runtime / release` risk scale. Missing/invalid risk scale yields
24
+ `INSUFFICIENT_EVIDENCE`; missing, conflicting, or different current lineage is
25
+ `RUNTIME_DIVERGENCE`.
26
+
27
+ Do not accept or translate another runtime evidence schema. Do not reconstruct
28
+ composition from `strategyConfigs`, mutable Redis state, research fingerprints,
29
+ or current source checkout metadata.
30
+
31
+ Do not infer live execution from the current local Redis config. Production
32
+ signals may run on another server. Request or inspect remote runtime artifacts
33
+ when local evidence is not the source of truth.
34
+
35
+ ## 2. Freeze the incident window and evidence
36
+
37
+ Freeze a half-open incident window `[start, end)`, affected symbols, runtime
38
+ trade/signal/evaluation ids, closed-candle timestamps, gate decisions/reasons,
39
+ order attempts/fills, fees/funding/slippage, exits, daemon lifecycle, and data
40
+ freshness. Hash every input before analysis.
41
+
42
+ Use only closed candles and signal-time-causal context. Preserve missing skip
43
+ evidence as missing; do not treat absent detailed skip records as proof that an
44
+ evaluation did not run.
45
+
46
+ ## 3. Establish parity before performance diagnosis
47
+
48
+ Compare runtime with replay/backtest for the same composition and incident
49
+ window:
50
+
51
+ - effective config and fingerprints;
52
+ - candle boundary and restored state/checkpoint;
53
+ - candidate signal and deterministic gate decision;
54
+ - allocator/risk/order status;
55
+ - entry/exit timestamps, prices, reason, fees, funding, and slippage.
56
+
57
+ Any historical backtest used for context must include `--cacheOnly` and the
58
+ maximum common cached window shared by the comparison. Do not update history to
59
+ make replay match live.
60
+
61
+ Classify unmatched items by evidence, not by assumption: no runtime evaluation,
62
+ gate/policy block, completed signal without fill match, runtime-only candidate,
63
+ backtest-only candidate, price/timestamp mismatch, state/config mismatch, or
64
+ context-data mismatch.
65
+
66
+ ## 4. Separate divergence from performance
67
+
68
+ If a material runtime/replay/config/context mismatch explains the incident,
69
+ return `RUNTIME_DIVERGENCE`. Do not judge core generalization from a non-parity
70
+ sample.
71
+
72
+ If parity holds, compare the incident and forward-incubation observations with
73
+ the frozen release distribution:
74
+
75
+ - `ALL`, `LONG`, and `SHORT` N/PnL/PnL-trade/PF/WR/DD/cadence;
76
+ - matched release regimes and causal setup cohorts;
77
+ - symbol/event concentration and simultaneous batches;
78
+ - expected loss streak, losing-period, and drawdown bounds;
79
+ - data lag and independent timestamp/event support.
80
+
81
+ Return `EXPECTED_DRAWDOWN` only when parity is established and the observation
82
+ remains within preregistered bounds. Return `GENERALIZATION_FAILURE` only when
83
+ parity is established and adequate new post-cutoff evidence breaches the frozen
84
+ generalization rule. Otherwise return `INSUFFICIENT_EVIDENCE`.
85
+
86
+ ## 5. Keep comparisons advisory
87
+
88
+ Do not alter core or gate thresholds in diagnose mode. Record a proposed causal
89
+ hypothesis as a new future release lineage.
90
+
91
+ If `llmComparison=ai-approved`, evaluate only deterministic-gate-approved live
92
+ or replay rows with the explicitly configured provider/model. Store agreement,
93
+ contradiction, and reasons as advisory evidence. Do not use the LLM to relabel
94
+ runtime divergence, override deterministic decisions, or trigger orders.
95
+
96
+ ## Suggested commands
97
+
98
+ Choose commands supported by the captured evidence and record every flag:
99
+
100
+ ```bash
101
+ yarn replay --startTime <start-ms> --endTime <end-ms> --cacheOnly
102
+
103
+ yarn runtime-parity --startTime <start-ms> --endTime <end-ms> --details
104
+
105
+ yarn ai-train --strategy <Strategy> --file <released-export-part1.jsonl> \
106
+ --localOnly --json -n 0 --terminalWindows=90,30,7
107
+
108
+ yarn runtime:scorecard \
109
+ --strategy <Strategy> \
110
+ --runtimeEvidence <verified-runtime-evidence.json> \
111
+ --replayEvidence <replay-runtime-evidence.json> \
112
+ --calibration <execution-calibration.json> \
113
+ --prospectiveEvidence <raw-core-gate-regime-summary.json> \
114
+ --releaseManifest <release-envelope.json> --diagnosisDays <7|30|90> \
115
+ --strategyReleaseRoot data/strategy-release
116
+ ```
117
+
118
+ Do not run a broad historical backtest unless it is needed to compare the
119
+ incident with the frozen release bounds; when needed, use the exact released
120
+ config and maximum common cached window only.
121
+
122
+ ## Diagnostic ready prompt
123
+
124
+ ```text
125
+ Use $strategy-forward-status for <Strategy>. Bind release record <path-or-id> to runtime evidence <path-or-id>, freeze incident window <start>..<end>, and check closed-candle/config/state/context/gate/execution parity before performance. Use only --cacheOnly historical comparisons over the maximum common cached window. Set llmComparison=<off|ai-approved>. Return exactly one evidence-status verdict and make no runtime or trading changes.
126
+ ```
@@ -0,0 +1,141 @@
1
+ # Direction-policy checkpoint
2
+
3
+ Use this checkpoint after the core rescue board and before concluding that no
4
+ composition can be salvaged. It tests whether a useful raw direction is being
5
+ obscured by the opposite direction or by the current deterministic gate.
6
+
7
+ ## Invariants
8
+
9
+ - Keep both directions enabled in the authoritative raw-core run and retain its
10
+ ALL/LONG/SHORT evidence.
11
+ - Never rewrite a failed raw-core result as profitable by deleting a side from
12
+ its metrics.
13
+ - Treat direction policy as explicit composition logic. Freeze, hash, and test
14
+ `both`, `long_only`, and `short_only` policies like other deterministic-gate
15
+ variants.
16
+ - Prefer a deterministic-gate direction block to changing the core side toggle:
17
+ it preserves raw counterfactual telemetry and makes the suppression visible.
18
+ - A core side toggle may be used only as an explicit equivalence candidate. It
19
+ must reproduce the corresponding gate-blocked entries and be separately
20
+ authorized before runtime configuration changes.
21
+ - Direction containment may produce a composition finalist even when the raw
22
+ ALL cohort failed. It does not waive maximum-covered economics, cost,
23
+ support, concentration, drawdown, or causality rules for the retained side.
24
+ Terminal calendar rows remain historical-readiness diagnostics.
25
+
26
+ ## Required trigger table
27
+
28
+ Evaluate every row before returning `UNSUITABLE_FOR_CURRENT_MARKET` or
29
+ `STOP_RESEARCH`:
30
+
31
+ Create the preregistered input and run the deterministic classifier before
32
+ freezing variants:
33
+
34
+ ```bash
35
+ node .codex/skills/strategy-release/scripts/direction-policy-checkpoint.mjs \
36
+ --input <direction-policy-input.json> > <direction-policy-decision.json>
37
+ ```
38
+
39
+ The input contains raw ALL/LONG/SHORT metrics, the frozen useful-side rule, and
40
+ current gate-approved side counts when available. Hash the input and output.
41
+ Do not override a required checkpoint in prose.
42
+
43
+ | Raw/gate evidence | Required action |
44
+ | ----------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
45
+ | One raw side has positive PnL and PF above 1 with adequate support, while the other side is the dominant aggregate loss | Run the five-variant direction-containment gate checkpoint. A no-gate-stop verdict is invalid. |
46
+ | A useful raw side receives zero or negligible current-gate approvals | Run side pass-through and direction-aware rescue variants. |
47
+ | The retained side is profitable long-window but fails a selection-grade recent guardrail or cost stress | Still evaluate the frozen direction policy; classify it as diagnostic or prospective-only unless it passes the release rule. Do not call it runtime-ready. |
48
+ | Both raw sides fail the preregistered side edge rule | No direction salvage is required, but the full diagnostic report remains mandatory. |
49
+ | Side support is too sparse for release inference | Keep the policy research-only or micro-forward eligible according to the verdict contract; do not manufacture historical support. |
50
+
51
+ `Useful raw side` is frozen before the checkpoint. By default it requires
52
+ positive full-development PnL, PF greater than 1, positive PnL/trade, and the
53
+ preregistered minimum support/cadence. A study may use a stricter rule but may
54
+ not invent a looser rule after seeing the result.
55
+
56
+ ## Five frozen variants
57
+
58
+ Freeze these variants before opening tuning/test economics:
59
+
60
+ 1. current deterministic gate with both directions;
61
+ 2. hard block of the failing direction (`long_only` or `short_only`);
62
+ 3. retained-side raw pass-through plus the same failing-direction hard block;
63
+ 4. current gate plus one rounded causal repair pocket for the failing direction;
64
+ 5. direction-aware replacement using the best preregistered policy per side,
65
+ including a hard block where that is the frozen candidate.
66
+
67
+ When the problem is instead a profitable side hidden by the gate, variants 2
68
+ and 3 become target-side raw pass-through and pass-through plus a protective
69
+ exclusion, matching the release workflow's recovery semantics. Record which
70
+ case is active so the same label cannot change meaning after outcomes are known.
71
+
72
+ For each variant report:
73
+
74
+ - raw and approved ALL/LONG/SHORT metrics;
75
+ - approval share and reject reasons by side;
76
+ - full, 3y, 4y, maximum-covered, 365d, 180d, 90d, 30d, and 7d windows;
77
+ - cost stress, folds/months, regimes, concentration, event fan-out, loss streak,
78
+ and drawdown;
79
+ - retained-side support and non-target removal/occupancy effects;
80
+ - train, tuning, and untouched-test partitions.
81
+
82
+ If a blocked side has zero approved rows, report explicit zero rows rather than
83
+ omitting it. The raw side remains visible beside the approved side.
84
+
85
+ ## Decision examples
86
+
87
+ ### Positive LONG, losing SHORT
88
+
89
+ Raw LONG `PnL > 0`, `PF > 1`; raw SHORT supplies most aggregate loss. Test
90
+ `long_only` and the remaining four variants. If LONG then fails a
91
+ selection-grade terminal cohort or cost stress, reject runtime readiness for
92
+ those reasons. A terminal loss alone may still leave the immutable policy
93
+ eligible for a risk-1 prospective test; a cost or portfolio-risk failure does
94
+ not. Keep underpowered/diagnostic 90d/30d/7d rows visible as `n/a` or diagnostic
95
+ evidence; do not let them reject the policy. Do not claim that SHORT made
96
+ testing impossible.
97
+
98
+ ### Profitable SHORT hidden by the gate
99
+
100
+ Raw SHORT passes its edge rule but current qN+ approves no SHORT rows. Test
101
+ SHORT pass-through, a causal SHORT pocket, protected SHORT, and the
102
+ direction-aware replacement. A zero-approval current gate is not a final
103
+ market-unsuitable result.
104
+
105
+ ### Both sides weak
106
+
107
+ If neither side passes the frozen useful-side rule, record `no_side_salvage`.
108
+ Still generate the complete raw-core and current-gate diagnostic reports and
109
+ chart before the verdict.
110
+
111
+ ## Required artifact
112
+
113
+ Persist a machine-readable checkpoint:
114
+
115
+ ```json
116
+ {
117
+ "schema": "tradejs-direction-policy-checkpoint/v1",
118
+ "trigger": "losing_side_contamination|profitable_side_hidden|no_side_salvage",
119
+ "rawCoreResearchId": "<id>",
120
+ "usefulSideRule": {},
121
+ "rawSideStatuses": {
122
+ "LONG": "useful|failed|insufficient",
123
+ "SHORT": "useful|failed|insufficient"
124
+ },
125
+ "variants": [
126
+ {
127
+ "id": "<id>",
128
+ "policy": "both|long_only|short_only|direction_aware",
129
+ "configSha256": "<sha256>",
130
+ "resultSha256": "<sha256-or-null>",
131
+ "status": "complete|invalid|not-run",
132
+ "decision": "retain|reject|diagnostic"
133
+ }
134
+ ],
135
+ "selectedPolicy": "both|long_only|short_only|direction_aware|null",
136
+ "reason": "<bounded evidence statement>"
137
+ }
138
+ ```
139
+
140
+ Hash and cite it from the final release note and decision input. A required but
141
+ missing checkpoint makes the release evidence incomplete.
@@ -0,0 +1,93 @@
1
+ # Directional parameter split
2
+
3
+ Use this checkpoint when one isolated global parameter change helps one
4
+ direction and harms the other. It converts a measured side conflict into a
5
+ causal core experiment; it is not permission to duplicate every config field.
6
+
7
+ ## Trigger
8
+
9
+ Run the classifier after a complete reconciled matched comparison:
10
+
11
+ ```bash
12
+ node .codex/skills/strategy-release/scripts/directional-parameter-checkpoint.mjs \
13
+ --input <directional-parameter-input.json> \
14
+ > <directional-parameter-decision.json>
15
+ ```
16
+
17
+ Classify each side with the preregistered side rule as `improved`, `worsened`,
18
+ `neutral`, or `inconclusive`. Require adequate independent support, the intended
19
+ trace transition, and a one-parameter config delta. A split is required only
20
+ for `LONG improved / SHORT worsened` or the mirrored conflict.
21
+
22
+ Do not trigger from aggregate PnL alone, one profitable symbol/event, an
23
+ outcome-derived cohort, or an unexplained occupancy change. When the original
24
+ candidate changed several fields, run an ablation first.
25
+
26
+ ## Implementation contract
27
+
28
+ Keep the original field as the backward-compatible fallback and add optional
29
+ directional overrides:
30
+
31
+ ```text
32
+ PARAM
33
+ PARAM_LONG
34
+ PARAM_SHORT
35
+ ```
36
+
37
+ Resolve only `undefined` to the fallback. Values such as `0`, `false`, and an
38
+ empty string are valid explicit overrides. With both overrides absent, old
39
+ configs, decisions, payloads, and state keys must remain exact.
40
+
41
+ Choose the implementation according to where the value acts:
42
+
43
+ - `decision_time`: resolve after direction is known; use a normal fallback
44
+ override.
45
+ - `detector_state`: a shared detector cannot simply switch values after a
46
+ signal appears. Use isolated replay-safe LONG and SHORT detector state or
47
+ reject the split as architecturally unsafe.
48
+ - `shared_lifecycle`: add the override, but preregister occupancy/cooldown and
49
+ opposite-side identity guardrails because one side can change the other's
50
+ opportunity set.
51
+
52
+ Include the effective LONG and SHORT values in detector/execution config
53
+ identity wherever they can alter replay state or decisions. Add focused tests
54
+ for implicit fallback parity, explicit LONG/SHORT resolution, zero/false
55
+ overrides, config isolation, replay reconstruction, and same-timestamp behavior.
56
+
57
+ ## Minimal research ablation
58
+
59
+ The global candidate is already evidence. Spend existing child/rescue slots,
60
+ not extra trials, on the smallest discriminating set:
61
+
62
+ 1. exact legacy control with no overrides;
63
+ 2. target-side-only override, keeping the opposite side at control;
64
+ 3. combined best-per-side override only when both side values have independent
65
+ prior evidence.
66
+
67
+ Use an explicit equal-overrides parity case in unit tests; backtest it only when
68
+ runner/config resolution parity is uncertain. Do not automatically test a full
69
+ Cartesian grid.
70
+
71
+ For the target side require the frozen improvement rule. For the non-target
72
+ side require exact signal/trade identity when architecture guarantees
73
+ independence. Otherwise report matched/added/removed identities, occupancy
74
+ spillover, N/cadence, PnL/trade, PF, WR, and side-only DD under a preregistered
75
+ non-regression rule. Keep aggregate portfolio DD as a separate guardrail.
76
+
77
+ ## Interpretation
78
+
79
+ - A successful target-only override supports a genuine directional parameter
80
+ asymmetry and may be carried forward as core behavior.
81
+ - If the target side improves but the opposite side changes through occupancy,
82
+ judge the whole causal composition rather than claiming isolation.
83
+ - If equal explicit overrides do not reproduce the global candidate, fix config
84
+ resolution/state identity before using any economics.
85
+ - If a detector-state split needs duplicated engines whose state cannot be
86
+ replayed exactly, retire the split rather than accepting runtime divergence.
87
+ - Preserve the original global parameter even after promotion so existing
88
+ configs remain reproducible and future configs can still choose symmetric
89
+ behavior.
90
+
91
+ Persist the classifier input/output, parameter semantics, fallback contract,
92
+ resolved configs, implementation tests, side identities, and decision in the
93
+ immutable family handoff.
@@ -0,0 +1,76 @@
1
+ # Evidence limitations and action ceiling
2
+
3
+ Classify an evidence problem before deciding whether to stop work. Do not use
4
+ the generic word `contamination` for limitations with different consequences.
5
+
6
+ ## Hard invalidation
7
+
8
+ These conditions invalidate selection economics and stop the affected run:
9
+
10
+ - outcome, future, or delayed-execution fields entered a signal-time decision;
11
+ - export and Redis N/W/L do not reconcile;
12
+ - the manifest is partial, failed, OOM, or belongs to another run;
13
+ - candidate and control use different causal windows, costs, or data revisions;
14
+ - a strategy state/reset leak mixes candidate cells;
15
+ - required candles or causal context are absent for the evaluated timestamps.
16
+
17
+ Repair or rerun the invalid evidence. A hard-invalid run cannot rank a
18
+ candidate, but the failure does not excuse skipping other valid families.
19
+
20
+ ## Research-grade provenance limitation
21
+
22
+ These conditions reduce the claim ceiling but do not stop paired research:
23
+
24
+ - the current deployable symbol cohort is applied retrospectively because
25
+ effective-dated exchange membership is unavailable;
26
+ - a chronological tail was exposed before variant freeze;
27
+ - an old uncommitted patch is not byte-reconstructable, while its causal
28
+ mechanism can be implemented again as a new candidate;
29
+ - remote deployment/account bindings are absent on the local research machine;
30
+ - prospective independent-event support is not yet available.
31
+
32
+ For a retrospective current-universe cohort:
33
+
34
+ 1. Label the estimand honestly: "performance of today's deployable cohort over
35
+ its available cached history", not historical exchange-wide performance.
36
+ 2. Keep control and candidates on the identical cohort/window and emphasize
37
+ matched setup/trade deltas over absolute PnL.
38
+ 3. Run membership sensitivity when the cache permits it: stable incumbent
39
+ symbols, minimum cached-history-age cohorts, and leave-one-symbol/event
40
+ concentration checks. Never invent listing/delisting dates.
41
+ 4. Use the result to select a prospective candidate. It cannot by itself
42
+ establish unconditional historical robustness or `READY_FOR_RUNTIME`.
43
+ 5. If the bounded composition otherwise qualifies, prepare or start the
44
+ authorized risk-1 micro-forward. Prospective current-universe evidence is the
45
+ correct way to resolve this limitation; waiting for a perfect historical
46
+ membership archive is not.
47
+
48
+ An exposed holdout follows the same action rule: it cannot establish a sealed
49
+ historical release claim, but it may select one immutable prospective
50
+ composition. Do not tune again after that selection.
51
+
52
+ ## Operational limitation
53
+
54
+ Missing local runtime bindings, credentials, or server Redis records do not
55
+ block local research. Produce the portable handoff and mark it
56
+ `requiresRuntimeBinding=true`. Resolve the binding only on the runtime server.
57
+
58
+ ## Action matrix
59
+
60
+ | Limitation | Continue core/gate research | Historical READY claim | Risk-1 micro-forward |
61
+ | ---------------------------------- | ------------------------------------- | ---------------------- | --------------------------------------- |
62
+ | Causal leakage/lookahead | No, repair evidence | No | No |
63
+ | Reconciliation/partial run | No, rerun | No | No |
64
+ | Retrospective current universe | Yes, paired/sensitivity | No | Yes |
65
+ | Exposed holdout | Yes, without retuning after selection | No | Yes |
66
+ | Missing old patch, mechanism known | Yes, new implementation lineage | No claim from old run | Yes after new evidence |
67
+ | Missing local server binding | Yes | Unaffected | Portable handoff locally; bind remotely |
68
+
69
+ Record one of these ceilings in the release progress artifact:
70
+
71
+ - `historical_ready_eligible`;
72
+ - `micro_forward_only`;
73
+ - `invalid_evidence`.
74
+
75
+ The ceiling controls claims, not whether Codex performs the next bounded
76
+ research action.
@@ -0,0 +1,157 @@
1
+ # Evidence retention
2
+
3
+ Preserve enough immutable evidence to reproduce every displayed metric and
4
+ understand every trial after Redis, caches, and exported files are deleted.
5
+
6
+ ## Immutable lineage
7
+
8
+ Create a new release or diagnostic record for each question and immutable
9
+ lineage. Never append a new run, changed composition, opened holdout, or revised
10
+ decision to an older result record.
11
+
12
+ Store internal research under the existing repository note contract:
13
+
14
+ ```text
15
+ $PROJECT_CWD/notes/<Strategy>/YYYY-MM-DD-<release-or-diagnose-slug>.md
16
+ ```
17
+
18
+ Keep `notes/` ignored and never stage or force-add it. Embed the complete
19
+ secret-free evidence in the note; mutable Redis keys and artifact paths are
20
+ inventory only.
21
+
22
+ ## Required release evidence
23
+
24
+ Retain:
25
+
26
+ - every `tradejs-release-progress/v2` input/output pair, including objective,
27
+ historical-candidate revalidation, artifact-backed round/rescue evidence, and
28
+ selected-composition lineage, evidence ceiling, and the next stage that
29
+ prevented a premature final verdict;
30
+ - the evidence-limitation classification (`hard invalidation`,
31
+ `research-grade provenance`, or `operational`) and sensitivity results;
32
+ - the trading thesis, opportunity map, hypothesis-role portfolio, and per-round
33
+ belief-ledger updates that explain why each experiment was worth running;
34
+ - experiment id, question, mode, preregistered acceptance rules, verdict, and
35
+ timestamp when each result partition was opened;
36
+ - the hashed strategy-history hypothesis inventory: behavior-relevant commits
37
+ and dirty patches, semantic/config hashes, evidence matches, classification,
38
+ bridge status, selected anchors, excluded duplicates/refactors, and unresolved
39
+ backlog;
40
+ - the prior-result bridge table with source/config/window/universe/cost lineage,
41
+ ALL/LONG/SHORT metrics, comparability class, rerun ids, and explanation for
42
+ every material regression or reproduction;
43
+ - append-only trial ledger containing the common control, all 3 causal families,
44
+ three refinement-round indices, rescue-board index, parent research IDs, and
45
+ every attempted candidate up to the 18-variant cap, with status, resolved
46
+ config, selection rank, cadence region, mechanism verdict, and rejection
47
+ reason;
48
+ - per-round authoritative metrics, setup matching, matched/added/removed/
49
+ changed-outcome and occupancy cohorts, trace-funnel/skip deltas, causal
50
+ regimes, cost stress, statistical guardrails, predicted-versus-observed
51
+ effects, and the evidence rationale for each next-round child variant;
52
+ - each round's hashed causal-handoff payload, including direct parents,
53
+ eligible carried control, mechanism verdict, failure mode, family decision,
54
+ and preregistered primary/falsification or refinement/robustness child deltas;
55
+ - the post-round-3 rescue board: complete candidate frontier, cadence-diverse
56
+ seed-selection inputs, each seed's dominant failure, one predicted rescue
57
+ delta per seed, rescue result, and the hard reason for any unused slot;
58
+ - the mandatory direction-policy checkpoint: frozen useful-side rule, raw side
59
+ statuses, trigger, five gate variants, raw-versus-approved ALL/LONG/SHORT,
60
+ policy/config/result hashes, and selected/rejected reason;
61
+ - every triggered directional-parameter checkpoint: one-field attribution,
62
+ side effects/support, resolution mode, classifier hashes, legacy fallback,
63
+ target-only/combined ablations, config/state isolation tests, and non-target
64
+ identity or occupancy-spillover evidence;
65
+ - selected isolated-long finalist and final core-plus-gate composition;
66
+ - exact git SHA/dirty diff inventory, config/gate/context fingerprints, and
67
+ tool/metric implementation SHA;
68
+ - ordered ticker universe, checksum, eligible/raw counts, connector, interval,
69
+ exact `[start,end)`, maximum-common-cache coverage proof, and point-in-time
70
+ membership lineage;
71
+ - fees, slippage, entry delay, `MAX_LOSS_VALUE`, AI mode, quality threshold,
72
+ provider/context settings, and BOTH-direction proof;
73
+ - exact commands, run ids, manifest status, planned/completed/error/OOM counts,
74
+ config ids, export merge/part ids, hashes, and Redis reconciliation;
75
+ - complete machine-readable ALL/LONG/SHORT metrics for full and required
76
+ terminal/cold-start windows, including zero-trade cohorts;
77
+ - the full diagnostic matrix even when no finalist qualifies: authoritative
78
+ control, best aggregate, best LONG, best SHORT, and every rescue/policy
79
+ attempt over full/3y/4y/max-covered/365d/180d/90d/30d/7d windows;
80
+ - control/candidate matched, removed, added, changed-outcome, occupancy, regime,
81
+ month, symbol, event, concentration, and capacity evidence;
82
+ - gate train/tuning/test boundaries, feature provenance, threshold rounding,
83
+ sealed-test flag/open timestamp, ablation, support, and one-round selection
84
+ decision; record any accidental early test exposure permanently;
85
+ - the complete `$ai-train-local-research` report sections and structured
86
+ full-period `ai-train --localOnly --chart -n 0` output, labelled
87
+ `diagnostic-only` when no composition qualifies;
88
+ - LLM comparison scope/provider/model/prompt/cost/fingerprint when enabled,
89
+ explicitly labelled advisory.
90
+
91
+ Preserve risk-scale changes as compact permanent `L` markers. Do not fork or
92
+ hide the unchanged core + gate evidence timeline merely because
93
+ `MAX_LOSS_VALUE` changed; retain the old/new values, timestamp, source artifact,
94
+ and normalization ratio.
95
+
96
+ Do not overwrite rejected hypotheses. Preserve partial/OOM/error runs with an
97
+ invalid-for-selection label so they are not silently retried as new evidence.
98
+
99
+ ## Required diagnose-live evidence
100
+
101
+ Retain:
102
+
103
+ - referenced immutable release id and exact composition fingerprints;
104
+ - incident `[start,end)`, remote/local source authority, collection timestamp,
105
+ affected symbols, runtime ids, signal/evaluation/analysis/order/trade keys;
106
+ - closed candles, detector state/checkpoint identity, baseContext/gate inputs,
107
+ gate decision and reasons, allocator/risk/order statuses;
108
+ - requested and actual entry/exit timestamps/prices, exit reason, quantity,
109
+ fees, funding, spread, impact, delay, slippage, and realized PnL;
110
+ - replay/backtest command and cached-coverage proof, match tolerance, matched and
111
+ unmatched classifications, nearest candidates, and per-field deltas;
112
+ - forward-incubation cutoff, independent event count, ALL/LONG/SHORT and regime
113
+ comparison with frozen release bounds;
114
+ - verdict precedence applied and unresolved evidence gaps.
115
+
116
+ ## Retention status
117
+
118
+ Use one of:
119
+
120
+ - `complete`: the record embeds all configuration, structured metrics, lineage,
121
+ and verdict evidence.
122
+ - `partial`: diagnostic material is useful but cannot reproduce every claim.
123
+ - `blocked`: a named missing or invalid input prevents the requested verdict.
124
+ - `legacy-partial`: historical evidence predates the contract and must not be
125
+ filled from current defaults.
126
+
127
+ Never mark evidence complete merely because a command exited zero. Verify the
128
+ finished manifest, hashes, counts, reconciliation, and machine-readable metrics.
129
+
130
+ ## Forward incubation
131
+
132
+ Write new post-cutoff observations to a new immutable record. Do not reopen the
133
+ selection/test tail or mutate the release note. Advisory/shadow candidates may
134
+ log counterfactual decisions and LLM comparisons, but they must not change
135
+ orders, runtime config, risk, daemon state, or promotion status without explicit
136
+ approval and a separate release decision.
137
+
138
+ ## Storage tiers and cleanup
139
+
140
+ Use the default tiering unless the user later changes it:
141
+
142
+ - operational Redis evidence: 3 days;
143
+ - reproducible verbose payloads: 14 days;
144
+ - verified, aggregated runtime bundles: 90 days;
145
+ - compact trial ledgers, release manifests, outcomes, gate disagreements,
146
+ diagnoses, and chart markers: permanent.
147
+
148
+ Review the plan before applying it:
149
+
150
+ ```bash
151
+ yarn strategy:release retention --input <retention-inventory.json>
152
+ yarn strategy:release retention --input <retention-inventory.json> --apply
153
+ ```
154
+
155
+ The first command is a dry run. The planner must keep unverified or unaggregated
156
+ evidence regardless of age so cleanup cannot destroy the only unresolved source
157
+ artifact.