Skip to content
Merged
4 changes: 2 additions & 2 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Stage A-G labels are continuation maturity lanes only; they do not replace the n
Company Workbench HTML Research Brief — Historical pre-fix evidence: Task 4 local matrix completed at `c8c313b9c`. Modal modifiers and active exposure fail closed. Broad-review repairs must be evaluated only through direct current-head local and exact-head CI evidence; their presence alone establishes neither gate. Exact-head repair evidence: commit `b69badfc80424d3a97fae5f77706aa6ed1533167` passed the 5,828-test full suite, the required dashboard, render, HTML, accessibility, public, and hygiene gates, branch/PR synchronization, and exact-head GitHub Actions run `30726301045`. The brief downloads an immutable offline view of existing saved evidence and prepared Python scenario math, preserves independent field gates and research-only wording, writes no repository artifact, and does not activate readiness or create a new calculation engine. Pilot packaging remains blocked on readiness freshness and source proof. Source rights, current data, hosted operation, human and screen-reader accessibility, independent workflow sessions, screening validation, and probability calibration remain open gates. Local engineering evidence does not establish source rights, current-market data, readiness activation, a new or professional line-item model, hosted operation, human or screen-reader conformance, independent validation, market fit, screening alpha, or probability calibration.
## Next: Ordered Maturity Work

Complete the direct local matrix and current-head local evidence first, then select the first incomplete safe roadmap priority. Remote synchronization, draft-PR updates, and exact-head CI require separate owner authorization. If the next gate needs an unavailable source, account, environment, reviewer, or elapsed event history, classify it once under **Externally blocked** and continue to the next executable priority. Passing local tests never completes an external gate. Evidence publication, snapshot, and retrieval timestamps must all be at or before the cutoff.
The prior engineering closure is incorporated in the default branch, and its automated engineering checks passed. Do not repeat that completed engineering slice without changed product bytes or separate owner authorization. Select the first incomplete safe roadmap priority. If the next gate needs an unavailable source, account, environment, reviewer, or elapsed event history, classify it once under **Externally blocked** and continue to the next executable priority. Passing local tests never completes an external gate. Evidence publication, snapshot, and retrieval timestamps must all be at or before the cutoff.

Documentation and routing now name Personal Research as the root default, Public and Operator as explicit modes, and legacy utilities as Operator-only compatibility surfaces. Reopen this contract when current repository evidence reproduces drift.

Expand Down Expand Up @@ -113,7 +113,7 @@ Final integrity commit `e3a090dba` ensures confirmation appends only the receipt

Confirmation-integrity commit `5a6c55921` binds every displayed preview field, preview time, and destination label to the exact receipt. If an append raises after it may have written, confirmation returns one-shot `save_pending_reload` with the exact record ID unless the locked ledger is provably unchanged; it never invites a blind duplicate retry.

Priority 4's local validator is frozen; its permitted real-data exit gate remains externally incomplete. Priority 6's provider-neutral authorization contract is complete locally; hosted implementation remains environment-dependent. Complete the direct local matrix and current-head local evidence first, then select the first incomplete safe roadmap priority. Remote synchronization, draft-PR updates, and exact-head CI require separate owner authorization.
Priority 4's local validator is frozen; its permitted real-data exit gate remains externally incomplete. Priority 6's provider-neutral authorization contract is complete locally; hosted implementation remains environment-dependent. The merged local matrix and exact-head CI are completed engineering evidence; select the first incomplete safe roadmap priority and require separate owner authorization for any future remote synchronization or release action.

### Priority 4 — Point-in-time benchmark and universe foundation

Expand Down
51 changes: 27 additions & 24 deletions docs/internal/COMMERCIAL_RESEARCH_BETA_CONTINUATION_GOAL_PROMPT.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
# Peer Lane Readiness Source Precedence Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Make Personal and Operator selected Data Health lanes use current saved readiness counts before older project-status counts, without changing readiness data or operating context.

**Architecture:** Keep the existing two inputs to `data_health_selected_lane_answer_cards()`. Make `dashboard_readiness_summary()` record count-level source-column provenance, then make the local resolver prefer only parseable, evidence-backed selected-profile counts, including zero. Project status remains the fallback and continues to provide source-setup and next-step context.

**Tech Stack:** Python 3.12, Streamlit, pytest, existing AppTest/render-smoke and browser-gate infrastructure.

## Global Constraints

- Data readiness first, analysis second, research decision last.
- Research-only: no recommendations, rankings, allocations, sizing, entry/exit guidance, transaction instructions, broker actions, performance claims, or fabricated data.
- Do not edit, regenerate, stage, reset, or clean any `data/` or `outputs/` path.
- Do not change readiness calculations, thresholds, source-rights decisions, navigation, or shared layout.
- No push, deployment, publication, tag, release, provider call, credential use, or external communication.

---

### Task 1: Make saved readiness authoritative for selected-lane counts

**Files:**
- Modify: `tests/test_dashboard_helpers.py`
- Modify: `src/dashboard.py:24856-24885`
- Modify: `src/data_health_summary.py:26-130`

**Interfaces:**
- Consumes: `data_health_selected_lane_answer_cards(selected_lane_key, readiness_freshness, project_status_payload=None, saved_readiness_summary=None)`.
- Produces: unchanged list-of-card interface; only readiness-count source precedence changes.

- [ ] **Step 1: Write the failing conflict and zero regressions**

Replace the stale test that expects project-status aliases to override saved readiness with behavior tests using literal conflicting values:

```python
def test_data_health_peer_lane_prefers_authoritative_saved_readiness_counts():
cards = dashboard.data_health_selected_lane_answer_cards(
"peers",
dashboard.FreshnessStatus(
"current",
"Saved readiness artifacts are current.",
"make readiness-preview TOP_N=20",
),
project_status_payload={
"summary": {"tickers_peer_ready": 29, "data_gaps": 207}
},
saved_readiness_summary={"peer_ready": 9, "blocked_by_data": 175},
)
rendered = " ".join(
str(value) for card in cards for value in card.values()
).lower()

assert "9 tickers have mapped peer trend context" in rendered
assert "175 locked input row(s)" in rendered
assert "29 tickers have mapped peer trend context" not in rendered
assert "207 locked input row(s)" not in rendered


def test_data_health_peer_lane_treats_saved_zero_as_authoritative():
cards = dashboard.data_health_selected_lane_answer_cards(
"peers",
dashboard.FreshnessStatus(
"current",
"Saved readiness artifacts are current.",
"make readiness-preview TOP_N=20",
),
project_status_payload={
"summary": {"tickers_peer_ready": 29, "data_gaps": 207}
},
saved_readiness_summary={"peer_ready": 0, "blocked_by_data": 0},
)
rendered = " ".join(
str(value) for card in cards for value in card.values()
).lower()

assert "0 tickers have mapped peer trend context" in rendered
assert "0 locked input row(s)" in rendered
assert "29 tickers have mapped peer trend context" not in rendered
```

The production mutation these tests catch is reversing the source order back to project-status-first or treating saved zero as absent.

- [ ] **Step 2: Run the two tests and verify RED**

Run:

```bash
python3 -m pytest -q -p no:cacheprovider \
tests/test_dashboard_helpers.py \
-k 'authoritative_saved_readiness_counts or treats_saved_zero_as_authoritative'
```

Expected: both tests fail because the current helper renders the project-status values 29 and 207.

- [ ] **Step 3: Implement the minimal precedence change**

Record the count keys whose source columns are present in
`dashboard_readiness_summary()` as `_count_evidence_keys`. Then change the
nested resolver so adapter-produced summaries use a saved count only when its
requested key is evidence-backed; explicit caller-supplied mappings without
metadata retain their current literal semantics:

```python
def resolved_count(*keys: str) -> int | None:
saved_count = (
_summary_optional_count(saved_summary, *keys)
if saved_count_evidence is None
or any(key in saved_count_evidence for key in keys)
else None
)
if saved_count is not None:
return saved_count
return _summary_optional_count(project_summary, *keys)
```

Resolve `data_sources_*` directly from `project_summary`; do not route those
operating-context counts through the saved-readiness resolver. Do not alter
recommendations, lane copy, or the function signature.

- [ ] **Step 4: Verify focused GREEN and existing fallbacks**

Run:

```bash
python3 -m pytest -q -p no:cacheprovider \
tests/test_dashboard_helpers.py -k 'data_health_peer_lane or data_health_price_lane'
```

Expected: the new conflict/zero cases pass; missing saved readiness still falls back to project status; absent counts still render unavailable.

---

### Task 2: Verify actual Personal and Operator route truth

**Files:**
- Test: `tests/test_dashboard_render_smoke.py`
- Test: `tests/test_research_mode_dashboard_contract.py`
- Test: `tests/test_dashboard_helpers.py`
- Runtime evidence: fresh temporary AppTest/browser outputs outside the repository.

**Interfaces:**
- Consumes: exact routes `/?mode=research&page=data-health&ticker=AVGO&lane=peers&drawer=proof` and `/?mode=operator&page=data-health&ticker=AVGO&lane=peers&drawer=proof`.
- Produces: current-byte evidence that both modes render 9 and reject stale 29 while preserving hierarchy, return path, mode, runtime, and no-advice boundaries.

- [ ] **Step 1: Run the affected static/render tests**

```bash
python3 -m pytest -q -p no:cacheprovider \
tests/test_dashboard_helpers.py \
tests/test_dashboard_render_smoke.py \
tests/test_research_mode_dashboard_contract.py
```

Expected: all tests pass with only known third-party warnings.

- [ ] **Step 2: Run a fresh two-route AppTest or browser proof**

Use the existing route/render harness on the two exact peer URLs. Assert each rendered result contains:

- `Selected Lane Answer — Peers`;
- `9 tickers have mapped peer trend context`;
- no `29 tickers have mapped peer trend context`;
- the correct Personal or Operator mode boundary;
- no exception or traceback;
- no recommendation, ranking, sizing, allocation, transaction, or performance claim.

Store all runtime evidence under a fresh `/tmp/stock-peer-lane-readiness-*` directory. Do not write screenshots or reports into the repository.

- [ ] **Step 3: Verify repository and artifact hygiene**

```bash
git diff --check
git status --short
git diff --name-only f88c4cdcdbffbf65928671b3acbfa51f6b1cdf48...HEAD
```

Expected: only the design, plan, production helper, and focused test files are intentional; no `data/` or `outputs/` path is changed or staged.

---

### Task 3: Independent review and local commit

**Files:**
- Review: complete branch diff against `f88c4cdcdbffbf65928671b3acbfa51f6b1cdf48`.

**Interfaces:**
- Consumes: final source/test diff and fresh verification artifacts.
- Produces: reviewer verdict with Critical/Important findings or READY.

- [ ] **Step 1: Request independent read-only review**

Ask the existing independent reviewer to inspect source precedence, zero semantics, fallback behavior, mode consistency, test quality, and protected-path hygiene. Do not edit while the review is active.

- [ ] **Step 2: Resolve any Critical or Important finding test-first**

For each reproduced finding, add a focused RED before changing production. Re-run only invalidated evidence.

- [ ] **Step 3: Run final verification and commit named paths**

After a READY verdict, run the final focused suite, `git diff --check`, and protected-path status verification. Stage exact named files only and commit locally. Do not push.
Loading