Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/counter_baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ conflicting_const 3 non-increasing
undeclared_py_import 2 non-increasing
dead_workflow_env 0 non-increasing
uncapped_surface 0 non-increasing
assertions 27582 non-decreasing
assertions 27600 non-decreasing
harness_rules_checked 84 non-decreasing
baseline_divergence 0 non-increasing
dup_precise_literal 3 non-increasing
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rest-express",
"version": "1.0.1271",
"version": "1.0.1272",
"type": "module",
"license": "MIT",
"scripts": {
Expand Down
21 changes: 21 additions & 0 deletions research/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -113420,3 +113420,24 @@ guessed, not read. Next session after a >24 h uptime window: read /api/health me
baseline, then ship A8 with the measured number. PRIORITY CHECK: nothing in priority 1–2 is broken; no
matured experiment is due. MERGE NOTE: docs-only; no deploy impact either way, merge after 4:00 PM ET by routine.
STARVED: no (A8 is queued but measurement-gated, not capacity-gated).

## 2026-11-04 [RULE-REVIEW] — T-BOT (system_config.py SHADOW_ENTRY_SLEEVES; mirrors server/entryShadow.ts, server/brain.ts) — ENTRIES LIVE AGAIN: stock and options entries order again (human directive)
VERSION: v1.0.1272 (shipped 2026-11-04 by the parent session; main was v1.0.1271)

Human directive (2026-11-04, verbatim): "figure out the option bleed and i didnt want you to stop trading thing like the floor it a paper account and see what work the best you know the goal is th beat the sp"

Change: SHADOW_ENTRY_SLEEVES "stocks,options" -> "off". The prior value was set 2026-10-28 (v1.0.1210, recorded as a human directive) and was in force 6 sessions. Mirrors updated: server/entryShadow.ts ENTRY_SHADOW_DEFAULTS, server/brain.ts BRAIN_CONFIG_MIRROR. The mechanism is untouched: VOLTRADE_SHADOW_ENTRIES still wins whenever present, so the rollback needs no deploy (set it to "stocks,options", or "options" to re-shadow only the options sleeve).

Downstream chain:
1. Options opens resume (tier SELL_CSP/BUY_PUT, scanner setups, evaluate_and_execute CSPs/covered calls/spreads, convexity QQQ puts, roll re-opens) -> option buying power is used again -> the options sleeve produces live results again, now with #1582 (a multi-leg strategy is closed as a unit) and #1583 (POS-KILL never kills one leg of a defined-risk structure) live on fresh entries for the first time.
2. Stock/ETF entries resume -> but in NEUTRAL the floor targets SPY_FLOOR_NEUTRAL 0.90 + DEFENSIVE_FLOOR_NEUTRAL 0.08 = 98% of equity, above the tier engine's 95% invested cap (TIER-KILL "Portfolio invested 96.7% >= 95%" at 14:46:59Z today) -> most stock entries stay blocked while NEUTRAL lasts; BULL (0.70 + 0.08) leaves about 17% of room, CAUTION (0.35 + 0.15) about 45%. This crowd-out is pre-existing and NOT changed here; it is a separate rule question that needs its own evidence.

Prior (stated before any live result): options expectancy per closed lot over the first 30 lots opened on this version lands between -10% and +5% (60% confidence), better than the historical -17.1% because the 11-02 fixes target the same-day churn that carried most of the loss (research/options_exit_study_2026-11-02.md: lots closed within a day lost -$9.8k); stock entries stay rare (< 5 a week) while NEUTRAL persists, because of the floor crowd-out.

Review date: 2026-12-04 (+20 trading days). The human decides keep / re-shadow per sleeve from live expectancy by sleeve (AI Engine page) and the account vs SPY over the same window. Rollback trigger (any one): options expectancy below -15% per closed lot after >= 30 closed lots opened on this version; the drawdown ladder halts (kill switches unchanged); the options-bleed diagnosis (in progress this session) finds a defect that makes new opens lose by construction.

Backtest: not run. This reverts a 6-session-old human-directed entry switch to the pre-2026-10-28 behaviour the live record already covers, and the honest test of the 11-02 fixes is live fills (REASONING STANDARD 9). Logged as an exploratory experiment with the review date above (PROMOTION RULES 3).

Tests: test_entry_shadow.py pins the new default "off" and that the env rollback still shadows both sleeves; server/entryShadow.test.ts the same; server/brain.test.ts keeps every assertion of the old all-shadowed scenario under an explicit config and adds a test for the live default; the flagRaw pin moves to "off". Touched-area suites: Python 89/89, Node/client 48/48.

STARVED: no (options-bleed diagnosis running; the fold-cache race fix is queued).
59 changes: 39 additions & 20 deletions server/brain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ test("long-term evidence: every quoted figure is still in its source file (doc d
test("flagRaw: env PRESENT wins (even empty / off); absent -> config default; True -> '1'", () => {
assert.deepEqual(flagRaw("VOLTRADE_REGIME_ENGINE", {}, BRAIN_CONFIG_MIRROR), { value: "1", source: "config" });
assert.deepEqual(flagRaw("VOLTRADE_REGIME_ENGINE", { VOLTRADE_REGIME_ENGINE: "" }, BRAIN_CONFIG_MIRROR), { value: "", source: "env" });
assert.deepEqual(flagRaw("VOLTRADE_SHADOW_ENTRIES", {}, BRAIN_CONFIG_MIRROR), { value: "stocks,options", source: "config" });
assert.deepEqual(flagRaw("VOLTRADE_SHADOW_ENTRIES", {}, BRAIN_CONFIG_MIRROR), { value: "off", source: "config" });
assert.deepEqual(flagRaw("VOLTRADE_REGIME_LABELS", {}, { REGIME_LABELS_DEFAULT: false }), { value: "", source: "config" });
});

Expand All @@ -70,31 +70,50 @@ test("parse: selection/sizing sets and the options crisis+vrp rule mirror regime
assert.deepEqual([...parseOptionsGates("0")], []);
});

test("status: defaults (both entry sleeves shadowed) — score inputs are SHADOW, floor/exits LIVE, dead code OFF", () => {
test("status: the 2026-10-28 config (both entry sleeves shadowed) — score inputs are SHADOW, floor/exits LIVE, dead code OFF", () => {
// The config default until the 2026-11-04 directive; still reachable via the env rollback.
const env = {};
assert.equal(status("stock_entries", env).status, "shadow");
const cfg = { ...BRAIN_CONFIG_MIRROR, SHADOW_ENTRY_SLEEVES: "stocks,options" };
assert.equal(status("stock_entries", env, cfg).status, "shadow");
assert.equal(status("stock_entries", env, cfg).status_source, "config");
assert.equal(status("options_entries", env, cfg).status, "shadow");
assert.equal(status("news", env, cfg).status, "shadow");
assert.match(status("news", env, cfg).detail, /nothing it touches is ordered/);
assert.equal(status("floor_basket", env, cfg).status, "live");
assert.equal(status("floor_basket", env, cfg).status_source, "config");
assert.equal(status("live_exits", env, cfg).status, "live");
assert.equal(status("live_exits", env, cfg).status_source, "code");
assert.equal(status("strategy_weights", env, cfg).status, "off");
assert.equal(status("google_trends", env, cfg).status, "off");
assert.equal(status("ml_v3", env, cfg).status, "shadow");
assert.equal(status("forecast", env, cfg).status, "shadow");
assert.equal(status("regime_sizing", env, cfg).status, "shadow");
// regime guards are gated but stock entries are shadowed -> they only block would-be entries
assert.equal(status("sel_knife", env, cfg).status, "shadow");
assert.match(status("sel_knife", env, cfg).detail, /would-be entries only/);
// the stress multiplier is replaced by the regime engine's sizing on the stock sleeve
assert.equal(status("stress_index", env, cfg).status, "off");
// convexity: CONVEXITY_OVERLAY.enabled is never read; the options shadow decides
assert.equal(status("convexity", env, cfg).status, "shadow");
assert.match(status("convexity", env, cfg).detail, /never read/);
assert.equal(status("third_leg", env, cfg).status, "shadow");
});

test("status: defaults since the 2026-11-04 directive (entries live) — entry sleeves and score inputs LIVE from config", () => {
const env = {};
assert.equal(status("stock_entries", env).status, "live");
assert.equal(status("stock_entries", env).status_source, "config");
assert.equal(status("options_entries", env).status, "shadow");
assert.equal(status("news", env).status, "shadow");
assert.match(status("news", env).detail, /nothing it touches is ordered/);
assert.equal(status("options_entries", env).status, "live");
assert.equal(status("options_entries", env).status_source, "config");
assert.equal(status("news", env).status, "live");
assert.equal(status("sel_knife", env).status, "live");
assert.equal(status("csp_block_guards", env).status, "live");
assert.equal(status("convexity", env).status, "live");
assert.equal(status("third_leg", env).status, "live");
assert.equal(status("floor_basket", env).status, "live");
assert.equal(status("floor_basket", env).status_source, "config");
assert.equal(status("live_exits", env).status, "live");
assert.equal(status("live_exits", env).status_source, "code");
assert.equal(status("strategy_weights", env).status, "off");
assert.equal(status("google_trends", env).status, "off");
assert.equal(status("ml_v3", env).status, "shadow");
assert.equal(status("forecast", env).status, "shadow");
assert.equal(status("regime_sizing", env).status, "shadow");
// regime guards are gated but stock entries are shadowed -> they only block would-be entries
assert.equal(status("sel_knife", env).status, "shadow");
assert.match(status("sel_knife", env).detail, /would-be entries only/);
// the stress multiplier is replaced by the regime engine's sizing on the stock sleeve
assert.equal(status("stress_index", env).status, "off");
// convexity: CONVEXITY_OVERLAY.enabled is never read; the options shadow decides
assert.equal(status("convexity", env).status, "shadow");
assert.match(status("convexity", env).detail, /never read/);
assert.equal(status("third_leg", env).status, "shadow");
});

test("status: env flips — entries live, regime flags off, an explicit empty env value wins over the config default", () => {
Expand Down
2 changes: 1 addition & 1 deletion server/brain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const PRIMARY_BUCKET_OUTCOME = "xa";

/** BASE_CONFIG values the status rules read — a MIRROR used only when the Python call failed (test_brain_evidence.py pins it). */
export const BRAIN_CONFIG_MIRROR: Readonly<Record<string, unknown>> = Object.freeze({
SHADOW_ENTRY_SLEEVES: "stocks,options",
SHADOW_ENTRY_SLEEVES: "off",
REGIME_ENGINE_ENABLED: true,
REGIME_SELECTION_DEFAULT: "all",
REGIME_OPTIONS_DEFAULT: "all",
Expand Down
17 changes: 12 additions & 5 deletions server/entryShadow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@ function slice(fromMarker: string, toMarker: string): string {
}

// ── flag ─────────────────────────────────────────────────────────────────────
test("default (env absent) shadows stocks and options, source config", () => {
assert.equal(ENTRY_SHADOW_DEFAULTS.VOLTRADE_SHADOW_ENTRIES, "stocks,options");
assert.deepEqual(entryShadowStatus({}), { stocks: true, options: true, source: "config" });
assert.equal(isEntryShadowed("stocks", {}), true);
assert.equal(isEntryShadowed("options", {}), true);
test("default (env absent) is live for both sleeves since the 2026-11-04 directive, source config", () => {
assert.equal(ENTRY_SHADOW_DEFAULTS.VOLTRADE_SHADOW_ENTRIES, "off");
assert.deepEqual(entryShadowStatus({}), { stocks: false, options: false, source: "config" });
assert.equal(isEntryShadowed("stocks", {}), false);
assert.equal(isEntryShadowed("options", {}), false);
});

test("the env rollback (VOLTRADE_SHADOW_ENTRIES=stocks,options) still shadows both sleeves", () => {
const env = { VOLTRADE_SHADOW_ENTRIES: "stocks,options" };
assert.deepEqual(entryShadowStatus(env), { stocks: true, options: true, source: "env" });
assert.equal(isEntryShadowed("stocks", env), true);
assert.equal(isEntryShadowed("options", env), true);
});

test("a PRESENT env var wins — every off value turns both sleeves live", () => {
Expand Down
3 changes: 2 additions & 1 deletion server/entryShadow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
*/

export const ENTRY_SHADOW_ENV = "VOLTRADE_SHADOW_ENTRIES";
// 2026-11-04 human directive: entries live again ("off"); prior "stocks,options".
export const ENTRY_SHADOW_DEFAULTS: Readonly<Record<string, string>> = Object.freeze({
VOLTRADE_SHADOW_ENTRIES: "stocks,options",
VOLTRADE_SHADOW_ENTRIES: "off",
});

/** shadow_portfolio.SHADOW_ENTRY_DECISION / SHADOW_REPEAT_DECISION. */
Expand Down
13 changes: 12 additions & 1 deletion system_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,18 @@
# (entry_shadow.flag_raw; Node mirror server/entryShadow.ts).
# Prior behaviour: every entry live (no key). Expected effect: no new
# stock/ETF/option positions; buying power stays in cash + floor.
"SHADOW_ENTRY_SLEEVES": "stocks,options",
# 2026-11-04 HUMAN DIRECTIVE (paper account; verbatim in research/
# experiments.md this date): the human did not want trading stopped:
# trade the sleeves live, see what works best, the goal is to beat SPY.
# Entries are LIVE again for both sleeves. Prior value "stocks,options"
# (2026-10-28 -> 2026-11-04). Expected effect: stock/ETF entries and
# options opens order again (the pre-2026-10-28 behaviour, now with the
# 2026-11-02 multi-leg close-as-a-unit and POS-KILL structure-hold fixes
# live for the first time); in NEUTRAL the floor (SPY_FLOOR_NEUTRAL 0.90
# + DEFENSIVE_FLOOR_NEUTRAL 0.08) still leaves little room under the 95%
# exposure cap for new stock entries (unchanged here). Rollback without
# a deploy: env VOLTRADE_SHADOW_ENTRIES=stocks,options (or =options).
"SHADOW_ENTRY_SLEEVES": "off",
# Target universe size — top N scored candidates per cycle
"T1_UNIVERSE_MAX_SIZE": 200,
# REGIME-SPECIFIC STOP SCALARS 2026-04-22
Expand Down
25 changes: 18 additions & 7 deletions test_entry_shadow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
exits live." — entry_shadow.py + server/entryShadow.ts.

Pinned here:
1. flag: BASE_CONFIG["SHADOW_ENTRY_SLEEVES"] = "stocks,options"; the env
1. flag: BASE_CONFIG["SHADOW_ENTRY_SLEEVES"] = "off" since the 2026-11-04
human directive (entries live again; "stocks,options" 2026-10-28 ->
2026-11-04); the env
var VOLTRADE_SHADOW_ENTRIES wins whenever it is PRESENT ("off"/"0"/""/
"none" = nothing shadowed); the Node mirror's default and decision
constants equal the Python ones.
Expand Down Expand Up @@ -73,13 +75,22 @@ def env(self, values):

# ── 1. flag ──────────────────────────────────────────────────────────────────
class TestFlag(unittest.TestCase):
def test_base_config_default_shadows_stocks_and_options(self):
self.assertEqual(BASE_CONFIG["SHADOW_ENTRY_SLEEVES"], "stocks,options")
self.assertEqual(entry_shadow.shadowed_sleeves({}), {"stocks", "options"})
self.assertTrue(entry_shadow.is_shadowed("stocks", {}))
self.assertTrue(entry_shadow.is_shadowed("options", {}))
def test_base_config_default_is_live_since_the_2026_11_04_directive(self):
# 2026-11-04 human directive (paper account): entries live again.
# The 2026-10-28 -> 2026-11-04 default was "stocks,options".
self.assertEqual(BASE_CONFIG["SHADOW_ENTRY_SLEEVES"], "off")
self.assertEqual(entry_shadow.shadowed_sleeves({}), set())
self.assertFalse(entry_shadow.is_shadowed("stocks", {}))
self.assertFalse(entry_shadow.is_shadowed("options", {}))
self.assertEqual(entry_shadow.status({}),
{"stocks": True, "options": True, "source": "config", "value": "stocks,options"})
{"stocks": False, "options": False, "source": "config", "value": "off"})

def test_the_rollback_value_still_shadows_both_sleeves(self):
# The env rollback the config comment names must keep working.
env = {"VOLTRADE_SHADOW_ENTRIES": "stocks,options"}
self.assertEqual(entry_shadow.shadowed_sleeves(env), {"stocks", "options"})
self.assertEqual(entry_shadow.status(env),
{"stocks": True, "options": True, "source": "env", "value": "stocks,options"})

def test_present_env_wins_including_off_values(self):
for v in OFF_VALUES:
Expand Down
Loading