-`trade_journal.db` — perf, orders, trades, `analysis_runs`, `config_store`. **This is the DB `compute_oss.py` reads** (`DB_PATH`, line 18).
-`consensus/signals.db` — `signals`, `consensus`.
**Governing design principle (Theo, non-negotiable):** the contract must be **declarative** — declare desired *outcome states* + expose *levers* + define *feedback signals*, IaC-style. NOT prescriptive step lists. Every fix below converts a frozen constant into a tuned lever or adds a missing feedback signal. Wherever you must hardcode, justify it as an irreducible exception.
**[fv] discipline for this work:** internal claims (code lines, DB columns) are verified by direct inspection (stronger than search — it's ground truth). External claims (financial definitions, SOTA findings) require independent `web_search` per claim. Label every assertion CONFIRMED / DISPUTED / UNVERIFIED. Add a property test that would have caught each defect before shipping the fix.
---
## 1. VERIFIED CURRENT STATE (the evidence base)
### Live OSS output (2026-07-01T14:19Z) — the smoking gun
| D5 | P-004/005/006 unimplemented | grep entire tree | `hedge_strategy`, `discovery_lens`, `source_provenance` = 0 hits in *.py, 0 DB columns |
| D6 | No adaptation persistence | DB introspection | tables `parameter_state`/`adaptations`/`regime_state` do not exist; `config_store` untouched since 2026-05-25 |
| D8 | Position size flat, `POSITION_SIZE_PCT` dead | `consensus/ross/sizing.py:7`, `config.py:138` | `calculate_position_size` returns `cfg.MAX_POSITION_NOTIONAL` which `= MIN_NOTIONAL` ($5); the 0.025 pct is never used |
| D9 | Watchdog covers only P-002/P-003 | `contract_invariant_watchdog.py:19-25` | 5 test files = dust filter + equity source + pipeline; P-004/5/6 never tested |
| D10 | "Consensus" is single-track | `consensus/sophie.py` + signals.db | all executed decisions score=1; universes disjoint by design |
- **Calmar = signed CAGR ÷ |maxDD|** — negative return MUST yield negative Calmar. (Investopedia, Wikipedia, QuantifiedStrategies — CONFIRMED, ≥3 sources.) → D1/D1b are unambiguous bugs.
- **FINSABER (arXiv:2505.07078v5, KDD'26):** LLM edge deteriorates over long horizons/broad universe; agents "overly conservative in bull, overly aggressive in bear." Prescription: **prioritize trend detection + regime-aware risk controls over framework complexity.** CONFIRMED (abstract).
- **StockBench (arXiv:2510.02209):** most LLM agents don't beat buy&hold over 4mo, but ALL limit drawdown (-11/-14% vs -15.2%). → realistic capturable edge = **drawdown control, not alpha.** CONFIRMED.
- **Agent Market Arena (arXiv:2510.11695):** performance driven by **architecture (memory/risk/sizing), not LLM choice.** CONFIRMED.
- **CLQT (arXiv:2606.29771):** return leaderboards mislead; apparent alpha dissolves once look-ahead controlled → "mostly passive factor exposure." Evaluate capability, not single score. CONFIRMED. → OSS is exactly the single-number leaderboard being warned against.
- **Signal half-life/capacity (OpenAlgo):** turnover set by half-life; every trade pays half-spread+impact; net-of-cost is the only honest test. CONFIRMED.
- **Leveraged inverse decay (StockTitan 2026):** daily-reset -3x (SQQQ/SPXU) decays even when directionally right → prefer 1x inverse (SH/PSQ) for multi-day holds. CONFIRMED. Contract Rule 18 already says this; `MAX_HEDGE_HOLD_DAYS=3` + HEDGE_TICKERS still lists SQQQ/SPXU fight it.
**Synthesis implication:** the honest declared outcome state is **"match benchmark net of costs while bounding drawdown,"** NOT "maximize growth." Re-weight the objective accordingly (P-011).
---
## 3. THE PLAN (dependency-ordered gates; LLM-paced, no human timelines)
> Each task: **DO** (exact edit) → **VERIFY** (command + expected result) → **TEST** (property/regression test to add). No task is "done" until its VERIFY passes and its TEST is committed.
### GATE 0 — Restore metric truth (BLOCKING; everything downstream is meaningless until this lands)
- CONSIDER: the OSS aggregate weight math (`:278-280`) assumes non-negative components — after this, re-derive so a negative Calmar drags OSS below floor. Verify OSS can now go below 0.5 on a losing month.
- VERIFY: `.venv/bin/python -c "import sys;sys.path.insert(0,'scripts');from compute_oss import compute_calmar as c;print(c(-2.35,-0.43,30), c(-2.35,0.43,30))"` → first value must be **negative**, second positive.
- VERIFY: `.venv/bin/python scripts/compute_oss.py` → with current -0.43% return, `oss` must now be **< 0.5** and `oss_trend` must NOT be "improving".
- Root cause: query needs `analysis_type` AND `result` columns that don't exist in `analysis_runs`.
- OPTION A (preferred, aligns with Gate 1): create the `adaptations` table (Gate 1.1) and repoint this query at it.
- OPTION B (interim): remove the `W_ADAPT * 0.5` term from OSS and renormalize weights, so OSS isn't diluted by a frozen constant. Document as temporary.
- VERIFY: grep confirms no silent `except: pass` returns a magic 0.5 that feeds OSS.
- TEST: assert `_compute_adapt_win_rate` raises or returns None (not 0.5) when the backing table/columns are absent — no silent defaults.
**0.3 — Live benchmark (kill the 0.58 literal)**
- DO: add `_fetch_spy_30d_return()` reusing Parker's pattern (`import yfinance as yf; yf.Ticker("^GSPC").history(period="1mo")`; 30d pct change). Thread into `:274` (alpha) and `:319` (beta).
- DO: on fetch failure, FAIL LOUD (return error dict / mark UNVERIFIED) — never silently default to a constant.
- VERIFY: `.venv/bin/python scripts/compute_oss.py` shows a `spy_30d_return` that changes day-to-day and ≠ 0.58; `rolling_alpha` flips sign when portfolio crosses SPY.
- TEST: `tests/test_benchmark_integrity.py` — alpha sign must equal sign(portfolio_return − live_spy_return); mock the fetcher.
**0.4 — Gate 0 acceptance**
- Re-run `compute_oss.py`; confirm it now reflects reality (the -$1.67 loss).
- Add 0.1/0.2/0.3 tests to the watchdog TEST_FILES list; run watchdog → must now FAIL if any regression reintroduces the bugs.
### GATE 1 — Make the optimization loop load-bearing (depends on Gate 0)
**1.1 — Persistence schema.** Create tables in `trade_journal.db`:
**1.2 — Move adaptation from LLM prompt to code.** Create `scripts/apply_adaptations.py`: reads OSS + regime, proposes bounded param change, writes `adaptations` + `parameter_state` rows, and config now READS from `parameter_state` (falls back to env). LLM cron `2ca03134ea62` becomes reporter, not actor.
- Declarative framing: contract declares target OSS ≥ 1.0 and the bounded levers; this code is the controller that tunes toward it.
**1.3 — Auto-unwind (Rule 8-14 guardrail).** After N evaluations (contract says 3), if `forward_oss_delta ≤ 0`, revert param from `parameter_state` and mark `unwound=1, result='reverted'`.
- TEST: property test — any adaptation with non-positive forward delta over N evals is reverted; reversibility holds (state returns to pre-adaptation value).
**1.4 — Wire win-rate.** Repoint `_compute_adapt_win_rate` at `adaptations.result='improved'`. Now OSS weight 0.15 is real.
- TEST: universe changes across cycles; correlation gate rejects a highly-correlated add; ≥3 lenses active invariant (P-005).
### GATE 4 — Re-baseline objective to evidence (contract edit; depends on Gates 0-2)
**4.1 — Rewrite objective declaratively (P-011).** Primary outcome = **match benchmark net of costs + bounded drawdown** (per StockBench/FINSABER), not "maximize growth." Re-weight OSS toward downside/drawdown metrics. Make hedge cap a regime-driven lever.
**4.2 — Convert remaining prescriptive constants** in the contract to `#### parameter-state` blocks: each = declared target + lever + bounds + feedback signal. The system tunes them; the contract stops fixing them.
**4.3 — Add P-007/008/009/010/011** to the invariant set + watchdog.
---
## 4. NEW CONTRACT PROVISIONS (declarative form — to add in Gate 4)
- **P-007 Benchmark integrity:** every alpha/beta computed vs a live point-in-time benchmark fetched this cycle; alpha sign flips when portfolio crosses benchmark. (Kills 0.58 literal.)
- **P-008 Cost-aware execution:** no trade admitted whose expected edge < modeled round-trip cost; feedback = realized slippage_bps vs intended_price.
- **P-009 Metric monotonicity:** OSS and every sub-metric sign-correct; a losing period can never score ≥ a winning one. (Property-tested.)
- **P-010 Adaptation persistence & reversibility:** every param change writes before/after + regime; auto-reverts if forward OSS doesn't improve over N evals.
- **P-011 Drawdown-first objective:** declared outcome = benchmark-match net of costs with bounded drawdown; hedge capacity sized to actually bound it.
---
## 5. EXECUTION ORDER & GUARDRAILS
1.**Gate 0 first, always.** Until OSS sees losses, every adaptation optimizes against a lie.
2. Human gate before contract edits (Gate 4) per Theo's 2-agent + 1-human policy. Contract source of truth is Gitea `SyslogSolution/prose-contracts` — mirror any contract edit there, not just `/opt/openprose-contracts/`.
3. Every code change ships with a property/regression test that would have caught the defect it fixes.
4. Pin any new cron jobs (unpinned LLM crons break on provider switch).
5. After each gate: run `compute_oss.py` + watchdog; record OSS before/after as evidence.
6. [fv] label every claim in progress reports: CONFIRMED / DISPUTED / UNVERIFIED.
## 6. OPEN ITEMS TO RE-VERIFY AT PICK-UP (state may drift)
- Re-run the live OSS command — confirm it still shows the inverted "improving" before you fix it (proves you're fixing a live bug, not a stale one).
- Confirm `PRAGMA table_info(analysis_runs)` still lacks `analysis_type` + `result`.
- Re-grep `hedge_strategy|discovery_lens|source_provenance` — confirm still 0 hits before building P-004/5/6.
- Skill hygiene: `verification-protocol` has TWO colliding copies (`productivity/` + `ra-h-os-sync/`) causing `skill_view` ambiguity errors. Load by full path or dedupe.
Gateway PID should exist with uptime > 60s.**Dual-gateway detection**: if more than one `gateway run` process is found, the gateway has a collision (typically one `--force` and one `--replace` process). Kill the newer/duplicate process, then restart the remaining gateway via PM2 (`pm2 restart mumuni-zulip`). Check gateway log for "Gateway running with 2 platform(s)" (not 1) to confirm Zulip reloaded.
**B3: Heartbeat Verification**
**B3: Heartbeat Verification**
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.