fix: backfill symbol_demand for sidebar-added symbols + analyst ratings schema fix

- Add await ctx.cache.subscribe() to addSymbol mutation so symbols
  added via the sidebar get registered in symbol_demand and yfinance
  jobs are queued immediately
- Backfill PEP, WYNN, STZ, CELH into symbol_demand + adapter_queue
- Upgrade yahoo-finance2 3.15.3 -> 3.15.4 and pass validateResult:false
  to quoteSummary() to handle Yahoo schema drift
- Add error detail logging for analyst ratings schema failures
- Update .gitignore with common ignores
This commit is contained in:
Investor Flow Build
2026-07-23 18:02:24 -04:00
parent 5ef2b2f060
commit e262187c3c
204 changed files with 25014 additions and 2934 deletions
+29 -68
View File
@@ -1,72 +1,33 @@
# ORCHESTRATOR HANDOFF — 2026-06-30 (Updated 17:55)
# Handoff pointer (updated 2026-07-18)
## Role & Goal
You are the ORCHESTRATOR (coordination only — do NOT write or review code). Drive all 26 vertical slices (DECOMPOSITION.md) to completion via TWO implementers that cross-review (no self-review: reviewer ≠ implementer):
- **ornith-35** = local omlx model `omlx/Ornith-35B` (35B, ~28-38 tok/s). GOOD for single-file/small implementations. CHOKES on big multi-turn (test-writing, huge prompts) — keep its dispatches SMALL/single-file.
- **qwopus35b** = remote `remote/qwopus35b` (131K context, single-request endpoint). GOOD for tests, reviews, multi-file adapters. Slower per-call (~5-15min).
This file previously held a 2026-06-30 multi-agent orchestrator snapshot. That snapshot is **obsolete**.
## STANDING PROCESS (critical)
1. **Clear ALL pending review tasks FIRST** via active driving (dispatch fixes + reviews, process completions, dispatch next — NO 5-min waits during this phase). Only resume the 5-min cadence once every review task is approved/complete.
2. **5-min cadence** for implementation monitoring (board/agents/logs each 5 min). After 3 checks not-done → inspect logs.
3. **NEVER kill a dispatch on low client CPU alone** (that = I/O wait). Check the omlx SERVER log `~/.omlx/logs/server.log` for active generation first. Remote: a "ping hangs" = busy (single-request processing), NOT dead.
4. **Agent self-complete bug**: implementers (pi --approve) run `status.py --transition complete` on their OWN task, bypassing code_review. Watch for tasks vanishing into `complete/` prematurely → restore: `mv .automaton/tasks/complete/<t> .automaton/tasks/<t>; printf 'implement\n' > .automaton/tasks/<t>/.state`.
## Read these instead
## Dispatch pattern
1. **`docs/FUNCTIONAL_DESIGN.md`** — what is Live / Backend-ready / UI-local / Stub / Missing
2. **`docs/TECH_DESIGN.md`** — stack, tRPC map, engines, schema debt, test counts
3. **`CONTEXT.md`** — domain glossary (not status)
4. **Obsidian** `investor-flow.md` — session orientation wiki
5. **`.automaton/tasks/`** — active gap tasks (implement pool after audit)
## Active gap tasks (created 2026-07-18)
| Priority | Task |
|----------|------|
| P0 | `fix-macro-commentary-tests` |
| P0 | `wire-sizing-risk-trpc-m20` |
| P1 | `persist-trade-plan-execution-loop` |
| P1 | `frontend-api-client-coverage` |
| P1 | `wire-emotion-logger-backend` |
| P2 | `strategy-lab-backtest-ui` |
| P2 | `screener-ui-filter-strategy` |
| P2 | `thesis-monitor-derisking-ui` |
| P2 | `options-convexity-sleeve-ui` |
| P3 | `reports-research-note-ui` |
| P3 | `schema-strategies-dedupe` |
## Quick verify
```bash
cd app/server && npm test # expect 2 known MacroRegime failures until P0 fixed
```
nohup env AUTOMATON_TASK=<task> pi --print -nc -np --approve --model <omlx/Ornith-35B|remote/qwopus35b> "$(cat /tmp/prompt.txt)" > /tmp/<log>.log 2>&1 & echo "PID=$!" > /tmp/<pid>.pid; disown
```
Write prompts via `cat > /tmp/prompt.txt <<'EOF' ... EOF` (quoted heredoc preserves $/backticks).
## Guard workarounds
- Structured `write`/`edit` tools are BLOCKED on the decomposed parent (DECOMPOSITION.md guard) → use **BASH** for ALL file writes.
- `git commit` is guard-intercepted (staleness) → run `python3 ~/.automaton/scripts/status.py --touch --task <task>` BEFORE every commit.
- Phase-graph: `implement→code_review` needs IMPLEMENTATION.md (write a brief one). `code_review:approved→complete` needs a bug_find gate → bypass: `printf 'complete\n' > .state`.
- `automaton_create_task` tool is BROKEN (no mkdir) → create tasks manually:
`mkdir -p .automaton/tasks/<name>; printf 'implement\n' > .state; printf '{"implement":"<author>"}\n' > .state.models; printf '' > .state.approvals`
- Claim conflicts (stale locks): `--release --task <t> --agent <a>` then `--claim --task <t> --agent <b>`.
- `.state.models` `{"implement":"<author>"}` = code author; the code_review claimer MUST differ (conflict-of-interest).
## omlx infra
- omlx server on **port 8000** (NOT 8080 — 8080 is the automaton dashboard). Logs: `~/.omlx/logs/server.log`. If a ping hangs, the server is busy (single-request) — be patient, don't kill.
## CURRENT STATE (after orchestrator session)
### All FIXES APPLIED ✅
1. **slice-10 (watchlistRepository.ts)**: Fixed double-encoding bug (single JSON.stringify, `{symbol, notes?}` objects, preserves notes on re-add/re-remove). 13/13 tests pass. → code_review
2. **slice-7 (institutionFlowEngine.ts)**: H1 fixed (removed `'C'` from INCREASE_CODES), M1 fixed (zero-share ambiguous → null, skip in insider_flow), M2 fixed (includeUnchanged option, default false filters out 'unchanged'). → code_review
3. **slice-15 (OptionsAdapter.ts + CacheRepository.ts)**: CRITICAL fixed (chain + expiry_dates handlers registered in HANDLERS map, kv_cache table in schema.sql), HIGH fixed (TTL comment updated, chain() now requires mandatory expiry). → code_review
4. **fix-edgar-tests**: Marked complete (stale — Edgar tests already green).
### IN-FLIGHT qwopus35b reviews (nohup — all dispatched)
- **qwopus rereview slice10** PID 21313 (log /tmp/qwopus-rereview-slice10.log)
- **qwopus rereview slice7** PID 21320 (log /tmp/qwopus-rereview-slice7.log)
- **qwopus rereview slice15** PID 21325 (log /tmp/qwopus-rereview-slice15.log)
- **qwopus review portfolio** PID 21331 (log /tmp/qwopus-review-portfolio.log)
Check: `kill -0 <pid>`.
### NEXT STEPS (after reviews complete)
1. Qwopus reviews come back → handle APPROVE (complete) or REQUEST CHANGES (dispatch omlx fixes).
2. If all APPROVE, mark complete and resume 5-min cadence for remaining slices.
3. Drive remaining slices per DECOMPOSITION order: 8 (institutional-dashboard, blocked by 7), 9 (sector-rotation, by 4+7), 11 (sizing-engine, by 10), 12 (strategy-lab-backtest, by 11), 13 (universe+screener, by 12), 14 (sector-confirmation, by 9+13), 17 (alerts, by 7+11+9+16), 18 (risk-engine, by 11), 19 (options-convexity, by 15+18), 20 (macro, by 18), 21-26 (check DECOMPOSITION.md).
### KEY FIX SUMMARY
- **watchlistRepository.ts**: Changed from double-encoding to single JSON.stringify with `{symbol, notes?}` objects. Added `readDefaultWatchlistRaw` helper. Notes preserved on multi-add. 13/13 tests pass.
- **institutionFlowEngine.ts**: H1 (removed 'C' from INCREASE_CODES), M1 (classifyTransactionDirection returns null for zero-share ambiguous), M2 (includeUnchanged option, default=false).
- **OptionsAdapter.ts + CacheRepository.ts**: chain + expiry_dates kind handlers registered, kv_cache table, TTL comment fixed, chain() requires mandatory expiry.
- **All 175 tests pass.** (TypeScript errors: EdgarAdapter.test.ts fetch type mismatch only — pre-existing.)
## COMPLETED slices
1 tracer, 2 auth/2FA/OAuth, 3 onboarding, 4 yfinance-backfill, 5 chart-lab M2, 6 SEC-EDGAR adapter, 16 X-cookie+Reddit adapters. fix-edgar-tests, chart-lab-panel-m2, fix-chartlab-findings, fix-spa-review-findings, fix-backend-review-findings.
## Repo/conventions
- /Users/laptran/Documents/investor-flow. Backend app/server/ (Node 26, node:sqlite, native TS, @trpc/server, yahoo-finance2, zod; test: `cd app/server && node --test --experimental-strip-types "src/**/*.test.ts"`). Frontend app/src/ (Next, Recharts, Tailwind; lint: `cd app && node --test --experimental-strip-types src/__tests__/primary-rule-lint.test.ts`).
- ADR-0007 (NO imperative trade verbs: buy/sell/you should/add to your/rotate into/action needed), P6 plain English, P7 shape+color+label.
- yf2 v3: `const yf = new YahooFinance()` (class, NOT v2 default-export); `yf.quote/chart/quoteSummary/options`.
- DESIGN.md + DECOMPOSITION.md (26 slices) at .automaton/tasks/complete/investor-flow-platform-design/.
## Framework issues filed (for ~/.automaton maintainer)
- ~/.automaton/tasks/orchestrator-session-framework-issues/ (8 issues incl. agent self-complete bypass #7, automaton_create_task broken #1, commit-guard staleness #3, code_review→complete bug_find gate #4, `--can-edit` PosixPath JSON serialization crash #9).
- ~/.automaton/tasks/add-orchestrator-polling-cadence/ (enforceable 5-min cadence + slow-vs-stuck heuristic).
- .automaton/ISSUES_LOG.md (older P0-P3 framework issues from pilot start).
- STALE ISSUES_LOG entries to IGNORE: "full_text_search ETag" + "tests still 1 failing" are RESOLVED (ETag fix landed, 16/16 green).