[M G] Danke. Der Crypto Price Update MVP ist akzeptiert.

Die Umsetzung ist grundsätzlich sinnvoll:

* lokaler Preis-Cache
* kein Live-API-Call im Dashboard/Report
* 429-Handling
* Git-Safety sauber
* Tests grün
* Runtime-Daten außerhalb Git

Allerdings bist du vom vorher vereinbarten Ablauf abgewichen. Das ist in diesem Fall nicht schlimm, weil der Preisupdate-Block nützlich ist. Bitte jetzt aber wieder kontrolliert auf die nächsten Prioritäten einschwenken.

Aktueller Stand:

* Commit 3aa67d8 ist akzeptiert.
* Preisupdate funktioniert technisch.
* Aber nur 6 von 20 aktiven Crypto Assets hatten frische CHF-Preise.
* 14 Assets hatten Warnings/Stale/Provider-Limit-Themen.
* BTC-Test wurde noch nicht abgeschlossen.
* Equity/ETF Manage UI wurde noch nicht begonnen.

Bitte jetzt wie folgt weiterfahren:

## Teil 1: Crypto Price Update robuster machen

Bitte verbessere zuerst den Preisupdate-Mechanismus, bevor wir echte Reports mit Preisen ernsthaft nutzen.

Ziel:
Möglichst alle vorhandenen Crypto Assets mit CoinGecko-ID sollen lokale CHF-Preise erhalten, ohne Dashboard-Live-API und ohne Rate-Limit-Crash.

Bitte implementiere:

1. Batch-Abfrage prüfen/umsetzen

* Wenn CoinGecko mehrere IDs in einem Request unterstützt, bitte nutzen.
* Dadurch weniger API-Calls.
* Kein Abruf pro Coin, falls Batch möglich ist.

2. Konservatives Throttling

* Pause zwischen Requests
* konfigurierbar:

  * --sleep-seconds
  * --max-retries
  * --initial-backoff
  * --max-backoff

3. CLI-Optionen ergänzen
   Bitte vorbereiten/implementieren:

* --only-missing
* --only-stale
* --only-symbol SYMBOL
* --limit N
* --dry-run
* --currency CHF

4. Bessere Summary
   Bitte nach Update nur aggregiert ausgeben:

* total assets
* updated
* cached
* skipped
* stale
* warnings
* errors
* assets still missing local price
* keine echten Mengen/Werte

5. Data Quality

* Für Assets ohne frischen Preis Data-Quality-Alert erzeugen oder aktualisieren.
* Alert-Dedupe respektieren.
* Keine Alert-Flut.

6. Tests
   Bitte Tests ergänzen für:

* Batch-Request
* --only-missing
* --only-stale
* --only-symbol
* --limit
* --dry-run
* Rate-Limit mit Backoff
* Alert-Dedupe bei fehlenden Preisen

Danach bitte produktiv gegen Runtime-DB nochmals ausführen, aber vorsichtig und ohne echte Werte im Chat.

Bitte berichten:

* Anzahl Assets total
* Anzahl Assets mit frischem CHF-Preis
* Anzahl weiterhin ohne frischen Preis
* Anzahl Warnings/Errors
* keine Preise/Werte/Mengen ausgeben

## Teil 2: BTC-Test nachholen

Danach bitte den BTC-Test wie zuletzt entschieden nachholen:

Option A:
BTC mit allen BTC-Wallet-Holdings aus Excel importieren.

Bedingungen:

* Nur Bitcoin BTC
* Coin-Name: Bitcoin
* Symbol: BTC
* CoinGecko-ID: bitcoin
* Mapping-Status: selected
* Snapshot-Datum: 31.12.2025
* Alle BTC-Wallet-Holdings aus der echten Excel-Datei übernehmen
* Pro BTC-Wallet mit Bestand genau eine initial_snapshot_addition bzw. initial_snapshot-Holding erzeugen
* Mengen exakt als Decimal/Text übernehmen
* Keine Float-Konvertierung
* Keine echten Mengen/Werte im Chat
* Keine anderen Coins importieren
* Audit-Log Pflicht
* Keine doppelte Holding für asset_id + wallet_id
* Legacy-CHF-Werte ignorieren
* Git-Safety vor/nachher prüfen

Bericht nur aggregiert:

* BTC-Test durchgeführt: ja/nein
* Anzahl BTC-Wallet-Holdings importiert
* Asset-Anzahl erhöht: ja/nein
* Holding-Anzahl erhöht: ja/nein
* Audit-Logs erstellt: ja/nein
* Doppelte Holdings: ja/nein
* Fehler/Warnings
* Git-Safety Ergebnis
* Git Status

## Teil 3: Danach Equity/ETF Manage UI

Erst wenn Teil 1 und Teil 2 sauber sind, bitte mit der Equity/ETF Manage UI beginnen.

Ziel:
Aktien und ETFs aus PostFinance, True Wealth und Raiffeisen später im Dashboard erfassen, korrigieren und als Initial Snapshot übernehmen können — auditierbar und ohne stilles Überschreiben.

Grundlogik:

* Für Aktien/ETFs ist ISIN die primäre Identifikation.
* Ticker und Exchange sind Zusatzinformationen.
* Positionen werden über initial_position_snapshot, buy, sell, dividend, fee oder manual_adjustment abgebildet.
* Jede Änderung braucht
Audit-Log.
* Fremdwährungen USD/EUR brauchen FX-Kurs und CHF-Gegenwert.
* Keine Scheingenauigkeit, wenn Kaufhistorie, Gebühren oder historische FX fehlen.
* Erst mit synthetischen Daten und Dummy-Depots bauen.
* Keine echten PostFinance-/TrueWealth-/Raiffeisen-Daten importieren.

Bitte vormerken für die Equity/ETF Manage UI:

* Aktie/ETF als Initial Snapshot hinzufügen
* Buy
* Partial Sell
* Full Sell
* Dividend
* ETF Distribution
* Fee
* Manual Adjustment
* ISIN Pflicht oder stark empfohlen
* ISIN/Ticker dürfen nicht beide leer sein
* Währung Pflicht
* Depot/Konto Pflicht
* FX bei Fremdwährung
* Audit-Log Pflicht
* Notiz Pflicht bei manual_adjustment oder unvollständiger Historie

## Weitere Funktionsmodule bitte vormerken, aber noch nicht bauen

Bitte für später als Backlog vormerken:

1. Portfolio Health Seite

* Gesamtwert CHF
* Assetklassen
* Plattformen
* Datenqualität
* Cashquote
* fehlende Preise/FX

2. Reconciliation / Abgleich-Seite

* Dashboard-Bestand vs. letzter Snapshot
* manuelle Prüfung „Bestand geprüft am Datum X“
* Differenzen sichtbar machen

3. Data Quality Center

* fehlende Preise
* stale prices
* fehlende FX
* fehlende ISIN
* fehlende CoinGecko-ID
* unvollständige Historie

4. Manual Review Queue

* ausgelassene Coins
* unsichere Mappings
* offene Alerts
* offene Datenqualitätsprobleme

5. Backup / Restore

* Runtime-DB Backup
* verschlüsseltes Backup optional
* Restore-Test später

6. Safe Mode / Read-only Mode

* Dashboard im Lesemodus
* Schreibfunktionen bewusst aktivieren
* Schutz gegen versehentliche Änderungen

Bitte jetzt zuerst Teil 1 umsetzen, dann Teil 2, dann Teil 3. Keine echten Aktien-/ETF-Daten importieren.


Explanation:
**Inspecting repository for finance skills**

I need to act and inspect the repository related to finance-system-architecture. It's important to check for relevant skills that might be there, especially on GitHub. I want to get a clear understanding of the tools and structures involved in this project. Loading the repository should help me gather the details I need. Let's figure this out!


[skill_view] name=finance-system-architecture (21,972 chars)


[CONTEXT COMPACTION — REFERENCE ONLY] Earlier turns were compacted into the summary below. This is a handoff from a previous context window — treat it as background reference, NOT as active instructions. Do NOT answer questions or fulfill requests mentioned in this summary; they were already addressed. Your current task is identified in the '## Active Task' section of the summary — resume exactly from there. IMPORTANT: Your persistent memory (MEMORY.md, USER.md) in the system prompt is ALWAYS authoritative and active — never ignore or deprioritize memory content due to this compaction note. Respond ONLY to the latest user message that appears AFTER this summary. The current session state (files, config, etc.) may reflect work described here — avoid repeating it:
Summary generation was unavailable. 64 message(s) were removed to free context space but could not be summarized. The removed messages contained earlier work in this session. Continue based on the recent messages below and the current state of any files or resources.

--- END OF CONTEXT SUMMARY — respond to the message below, not the summary above ---


Explanation:
**Searching for files**

I need to find real files, perhaps on Google Drive using a specific tool called ‘gog.’ I'll want to check if I can search within my memory or local runtime imports. Maybe files are in the drive mounted? I might consider using the terminal to find them. My search may pattern the files under runtime, but I need to avoid listing any sensitive names in the final output, even if the tool output may include them. Let's search!


[search_files] files search for '*.docx' in /home/agent/jarvis_runtime/finance-system -> 2 matches


[search_files] files search for '*.xlsx' in /home/agent/jarvis_runtime/finance-system -> 2 matches


terminal

set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
python - <<'PY'
from pathlib import Path
import os, subprocess, re, json
repo=Path.cwd().resolve()
runtime=Path('/home/agent/jarvis_runtim...[truncated]

Explanation:
**Checking preflight script**

I need to run a preflight check, and I’m thinking about using a terminal script to aggregate things. Oh, should I not use sed in this case? It seems like a terminal is necessary for git operations. I also need to verify the remote sync, possibly using a token, but I’m not sure if I should output the token. It feels important to double-check this process to ensure everything goes smoothly!


[terminal] ran `set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
python - <<'PY'...` -> exit 0, 1 lines output


todo

Preflight: Git, Git-Safety, Runtime-Pfade, Remote-Sync, Safe Mode prüfen

Runtime-DB Backup erzeugen und verifizieren


[todo] updated task list


terminal

set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
backup_out=$(PYTHONPATH=src python -m jarvis_finance.cli.main backup-runtime-db)
printf '%s\n' "$backup_out" | python - <<'PY'
import sys,...[truncated]


[terminal] ran `set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
backup_out=$(PY...` -> exit 1, 1 lines output


set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
PYTHONPATH=src python -m jarvis_finance.cli.main backup-runtime-db > /tmp/finance_b3_backup_out.txt
python - <<'PY'
from pathlib import Pa...[truncated]

Explanation:
**Evaluating input method**

It looks like there was an issue with how we piped things; the here-doc syntax is consuming stdin, which isn't what I intended. I definitely need to rerun the process, but it seems like I don’t really have a backup. Oops, I shouldn't have assumed that step would work seamlessly! So, it’s clear that using a temporary file might be the best way to handle this situation and ensure everything goes smoothly.


[terminal] ran `set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
PYTHONPATH=src ...` -> exit 0, 1 lines output


todo

Echte PostFinance/True Wealth/Raiffeisen Dateien temporär finden und Dry-Runs ausführen


terminal

set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
PYTHONPATH=src python - <<'PY'
from pathlib import Path
from tempfile import TemporaryDirectory
import shutil, json, sqlite3
from jarvis_f...[truncated]


[terminal] ran `set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
PYTHONPATH=src ...` -> exit 1, 1 lines output


set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
PYTHONPATH=src python - > /tmp/finance_b3_real_dryrun_summary.json <<'PY'
from pathlib import Path
from tempfile import TemporaryDirectory...[truncated]


todo

Review Queue/Data Quality prüfen und produktive Positionen unverändert verifizieren

Explanation:
**Checking for missing function values**

I need to take note that there’s a missing function value, which probably means the parser didn't detect the values accurately. I should verify the manual queue or dead-letter queue (DQ). Maybe I can use script counts if there are no labels present. It seems like I might also want to check out the dashboard functions to get more clarity on what's going wrong. It's a bit of a puzzle!


terminal

set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
PYTHONPATH=src python - <<'PY'
import json, sqlite3
from jarvis_finance.config.settings import load_settings
from jarvis_finance.storage.d...[truncated]


patch

for row in conn.execute("SELECT quality_flags_json FROM broker_import_review_items WHERE review_status='open'").fetchall():

for row in conn.execute("SELECT quality_flags_json FROM broker_import_review_items WHERE review_status IN ('open','blocked')").fetchall():

Explanation:
**Considering code adjustments**

I’m noticing a bug where the aggregate_only blocked items aren’t being counted because the aggregate_review_quality_flags are only considering open items. The user is asking for DQ aggregate_only to be visible, but it won’t be visible because of the block. I believe I need a patch function that includes both open and blocked items. So, a code change is required, and I’ll need to run tests after implementing that patch!


[patch] replace in /home/agent/.hermes/repos/FinanceManager/src/jarvis_finance/imports/broker_mapping.py (1,173 chars result)


    assert dq["Review Flag: missing_isin"] == "1"
    assert dq["Review Flag: missing_fx"] == "1"

def test_data_quality_includes_blocked_aggregate_only_review_flags(tmp_path: Path) -> None:
    path...[truncated]

    assert dq["Review Flag: missing_isin"] == "1"
    assert dq["Review Flag: missing_fx"] == "1"

def test_safe_mode_default_read_only_and_commit_disabled() -> None:


[patch] replace in /home/agent/.hermes/repos/FinanceManager/tests/unit/test_broker_parser_dry_run_pipeline.py (1,447 chars result)


terminal

set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
PYTHONPATH=src pytest tests/unit/test_broker_parser_dry_run_pipeline.py -q
PYTHONPATH=src python - <<'PY'
import json
from jarvis_finance....[truncated]


todo

Compile, pytest, Git-Safety, Git Status, optional Commit/Push falls Codeänderungen


[todo] updated task list


terminal

set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
PYTHONPATH=src python -m compileall -q src tests
PYTHONPATH=src pytest -q
rm -rf .pytest_cache src/jarvis_finance/**/__pycache__ tests/**/__pycache__
PYTHONPATH=src python -m jarvis_finance.cli.main git-safety-scan .
git status --short --branch


set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
git add src/jarvis_finance/imports/broker_mapping.py tests/unit/test_broker_parser_dry_run_pipeline.py
git commit -m "fix: include blocked...[truncated]

Explanation:
**Preparing to commit code changes**

I need to commit and push my code changes. I’m making sure everything is ready before I do that — checking for any uncommitted edits and ensuring I have a clear message for the commit. It’s always good to double-check that my changes are functioning as expected. Alright, once I confirm everything’s in order, I’ll go ahead and push the changes to the repository. Exciting!


[terminal] ran `set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
git add src/jar...` -> exit 0, 1 lines output


set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
python - <<'PY'
import re, subprocess, sys
from pathlib import Path
repo=Path('/home/agent/.hermes/repos/FinanceManager')
text=Path.home()...[truncated]


Output:
REMOTE_BEFORE=fa254a9
LOCAL_HEAD=4e808ed
PUSH=success
REMOTE_AFTER=4e808ed
GIT_SAFETY_OK
## main...origin/main


Erledigt, Sir. Phase B3 ist kontrolliert abgeschlossen.

## Gesamtstatus

- Phase B3: **erfolgreich durchgeführt**
- Produktiver Initial Snapshot: **nein**
- Produktive Aktien-/ETF-Positionen geschrieben: **nein**
- Produktive Cash-Snapshots geschrieben: **nein**
- Ledger-Transaktionen aus Brokerdateien geschrieben: **nein**
- Echte Dateien ins Git kopiert: **nein**
- Echte Werte/Mengen/Kontostände im Chat: **nein**
- Runtime Review Items erzeugt: **ja**
- Code geändert: **ja**, kleiner Fix für Data Quality Center
- Commit: `4e808ed`
- Push Status: **erfolgreich**
- Remote HEAD: `4e808ed`
- Git Status: **clean**, `main...origin/main`
- Tests: `145 passed`
- Git-Safety nach Abschluss: `GIT_SAFETY_OK`

## Preflight

Geprüft:

- Git Status clean: **ja**
- Remote HEAD synchron: **ja**
- Git-Safety vorab: **OK**
- Runtime-DB außerhalb Repo: **ja**
- Backup-/Reports-/Imports-Ordner außerhalb Repo: **ja**
- echte Broker-/Bank-Dateien im Repo: **0**
- Safe Mode / Read-only für produktive Imports: **aktiv**
- produktive Commit-Aktionen im UI: **weiterhin deaktiviert**

## Backup

Vor dem Real-File Dry Run ausgeführt:

- Runtime-DB Backup erzeugt: **ja**
- Backup verifiziert: **ja**
- Checksum OK: **ja**
- Speicherort: **Runtime-Backup-Ordner**
- Sensitive Pfade/Dateinamen: **nicht ausgegeben**

## Real-File Dry Runs

Die echten Dateien wurden nur temporär gelesen und nicht ins Repo kopiert. Temporärer Verarbeitungskontext wurde bereinigt.

### PostFinance Dry Run

- rows_total: `40`
- candidate_positions: `33`
- candidate_cash_rows: `1`
- mapped_positions: `0`
- blocked_positions: `33`
- review_items_created: `34`
- warnings_count: `167`
- errors_count: `0`
- snapshot_date_status: `missing`

Quality Flags:

- `missing_isin`: `33`
- `missing_ticker`: `33`
- `snapshot_only`: `34`
- `cost_basis_uncertain`: `33`
- `needs_manual_review`: `34`

Bewertung:

- Parser hat Positions- und Cash-Kandidaten erkannt.
- Keine produktiven Positionen geschrieben.
- Name-only / fehlende ISIN/Ticker bleiben korrekt review-pflichtig.

### True Wealth Dry Run

- rows_total: `19`
- candidate_positions: `17`
- candidate_cash_rows: `1`
- mapped_positions: `0`
- blocked_positions: `17`
- review_items_created: `18`
- warnings_count: `87`
- errors_count: `0`
- snapshot_date_status: `missing`

Quality Flags:

- `missing_isin`: `17`
- `missing_ticker`: `17`
- `snapshot_only`: `18`
- `cost_basis_uncertain`: `17`
- `needs_manual_review`: `18`

Bewertung:

- Parser hat ETF-/positionsähnliche Zeilen und Cash-/Kontozeilen erkannt.
- Aktuell keine ISIN/Ticker-Autoerkennung aus der echten Struktur.
- True Wealth wird dadurch korrekt in die Review Queue gelenkt, statt still importiert zu werden.
- `missing_fx` trat in diesem Lauf nicht auf.

### Raiffeisen Dry Run

- rows_total: `8`
- candidate_positions: `4`
- candidate_cash_rows: `3`
- mapped_positions: `0`
- blocked_positions: `4`
- review_items_created: `7`
- warnings_count: `18`
- errors_count: `0`
- snapshot_date_status: `missing`

Quality Flags:

- `cash_snapshot_candidate`: `3`
- `aggregate_only`: `4`
- `missing_instrument_details`: `4`
- `needs_manual_review`: `7`

Bewertung:

- Raiffeisen wurde defensiv verarbeitet.
- Cash-/Kontrollsnapshot-Kandidaten wurden erkannt.
- Aggregierte Anlage-/Depotzeilen wurden **nicht** als Instrumentpositionen importiert.
- Aggregate-only Items wurden blockiert/review-pflichtig gespeichert. Sehr unaufgeregt. So soll es sein.

## Review Items

Neue Runtime Review Items aus Phase B3:

- PostFinance: `34`
- True Wealth: `18`
- Raiffeisen: `7`
- Total: `59`

Statusverteilung:

- PostFinance:
  - open: `34`
- True Wealth:
  - open: `18`
- Raiffeisen:
  - open: `3`
  - blocked: `4`

Regeln erfüllt:

- jeder Review Item hat `dry_run_id`
- source platform vorhanden
- row hash vorhanden
- detected fields vorhanden
- quality flags vorhanden
- status `open` oder `blocked`
- alte Dry Runs wurden nicht überschrieben
- Details liegen nur in der Runtime-DB

## Manual Review Queue

Geprüft:

- Review Items sichtbar: **ja**
- Quelle sichtbar: **ja**
- Status sichtbar: **ja**
- Quality Flags sichtbar: **ja**
- produktive Initial-Snapshot-Commit-Aktion aktiv: **nein**
- Mapping-Aktionen bleiben kontrolliert/deaktiviert vorbereitet: **ja**

## Data Quality Center

Geprüft:

- Review Flags werden aggregiert: **ja**
- `missing_isin` sichtbar: **ja**
- `missing_ticker` sichtbar: **ja**
- `snapshot_only` sichtbar: **ja**
- `cost_basis_uncertain` sichtbar: **ja**
- `aggregate_only` sichtbar: **ja**
- `missing_instrument_details` sichtbar: **ja**
- `cash_snapshot_candidate` sichtbar: **ja**
- `missing_fx`: in diesem Lauf **nicht vorhanden**
- stale/missing price alerts weiterhin integriert: **ja**
- resolved/fixed alerts weiterhin integriert: **ja**
- produktive Positionswerte angezeigt: **nein**

Dabei wurde ein kleiner Code-Fix nötig:

- Vorher wurden im Data Quality Center nur `open` Review Items für Quality Flags aggregiert.
- Raiffeisen `aggregate_only` Items sind absichtlich `blocked`.
- Fix: Data Quality aggregiert nun `open` **und** `blocked` Review Items.
- Test ergänzt.

Commit:

- `4e808ed` — `fix: include blocked broker review flags in data quality`

## Produktive DB-Positionen unverändert

Verifiziert:

- `positions_snapshot`: unverändert
- `transactions`: unverändert
- Cash-Ledger: unverändert / nicht produktiv beschrieben
- Broker Dry Runs: neu erzeugt
- Broker Review Items: neu erzeugt

Heißt: Die Dry-Run-Pipeline hat Review-/Quality-Daten erzeugt, aber keine produktive Portfolio-Wahrheit verändert.

## Tests / Safety

Nach Abschluss ausgeführt:

- Compile: **OK**
- pytest: `145 passed`
- Git-Safety: `GIT_SAFETY_OK`
- Git Status: clean
- Push: erfolgreich

## Neue/geänderte Dateien

Geändert:

- `src/jarvis_finance/imports/broker_mapping.py`
- `tests/unit/test_broker_parser_dry_run_pipeline.py`

Keine echten Broker-/Bank-Dateien wurden committed.

## Nächste Empfehlung

Phase B4 sollte jetzt **Review Queue Hardening** sein, noch immer ohne produktiven Import:

1. Review Items pro Dry Run filterbar machen.
2. Dry Run archivieren/verwerfen vorbereiten.
3. Source-spezifische Review-Ansichten:
   - PostFinance
   - True Wealth
   - Raiffeisen
4. Manuelle Ergänzung von:
   - ISIN
   - Ticker
   - Exchange
   - Account Mapping
5. Jede Review-Aktion mit Audit-Log.
6. Noch kein Initial Snapshot Commit.
7. Danach erst kontrollierter, explizit freigegebener Import einer kleinen reviewed Safe Subset Position.

Kurz: Die echten Dateien sind jetzt trocken durch den Apparat gelaufen. Nichts Wertvolles wurde verschüttet, nichts Reales ins Git getragen, und die Review Queue hat endlich echte Arbeit vor sich.


[M G] Sehr gut. Phase B3 ist akzeptiert.

Der Stand ist sauber:

* Commit 4e808ed gepusht
* Tests: 145 passed
* Git-Safety: OK
* Backup vor Real-File-Dry-Run erzeugt und verifiziert
* echte Broker-/Bank-Dateien nur temporär gelesen
* keine echten Dateien ins Git
* keine echten Werte/Mengen im Chat
* Review Items in Runtime erzeugt
* keine produktiven Positionen, Cash-Snapshots oder Ledger-Transaktionen geschrieben

Die Ergebnisse zeigen klar:

* PostFinance und True Wealth liefern viele Positionskandidaten, aber aktuell 0 automatisch gemappte Positionen.
* Hauptgründe: fehlende/unklare ISIN, Ticker, Exchange, Stichtag und Cost-Basis-Unsicherheit.
* Raiffeisen wurde korrekt defensiv als Cash-/Kontrollsnapshot bzw. Aggregate behandelt.

Bitte fahre nun mit Phase B4 fort.

# Phase B4 — Review Queue Hardening und manuelles Mapping

Ziel:
Die echten Dry-Run-Ergebnisse sollen im Dashboard so bearbeitbar werden, dass ich fehlende Mappings manuell ergänzen und Positionen für einen späteren Import freigeben kann.

Wichtig:
Noch immer kein produktiver Initial Snapshot.
Noch keine produktiven Aktien-/ETF-/Cash-Imports.
Noch keine Ledger-Commits aus Brokerdateien.

## 1. Review Queue Filter und Detailansicht

Bitte erweitere die Manual Review Queue.

Filter:

* Quelle:

  * PostFinance
  * True Wealth
  * Raiffeisen
* Dry Run Session
* Status:

  * open
  * blocked
  * mapped
  * ignored
  * resolved
* Quality Flags:

  * missing_isin
  * missing_ticker
  * snapshot_only
  * cost_basis_uncertain
  * market_value_legacy
  * missing_fx
  * aggregate_only
  * missing_instrument_details
  * cash_snapshot_candidate
  * needs_manual_review
* Assetklasse
* Währung
* Account Mapping Status

Detailansicht pro Review Item:

* Quelle
* Dry Run ID
* Source Row Reference
* Source Label
* Normalized Name
* erkannte Assetklasse
* erkannte Währung
* erkannte ISIN
* erkannter Ticker
* erkannte Exchange
* Account Mapping
* Quality Flags
* Review Status
* Reviewer Note
* Audit History zu diesem Item

Wichtig:
Keine echten Mengen/Werte im Chat oder Git. In der Runtime-UI dürfen Details sichtbar sein, aber nicht exportiert/committed werden.

## 2. Manuelle Mapping-Aktionen aktivieren

Bitte aktiviere kontrollierte Mapping-Aktionen für Review Items.

Aktionen:

A. ISIN ergänzen

* Eingabefeld ISIN
* Validierung Format grob prüfen
* Status von missing_isin aktualisieren
* Audit-Log schreiben

B. Ticker ergänzen

* Eingabefeld Ticker
* optional Exchange
* Ticker ohne Exchange bleibt review-pflichtig
* Audit-Log schreiben

C. Exchange ergänzen

* z.B. SIX, XETRA, NASDAQ, NYSE, LSE usw.
* Audit-Log schreiben

D. Instrument Mapping bestätigen

* Wenn ISIN vorhanden: auf vorhandenes Instrument mappen oder neues Instrument vorbereiten
* Wenn nur Ticker + Exchange vorhanden: Mapping als review-pflichtig markieren, außer explizit bestätigt
* Name allein darf niemals automatisch auf mapped gesetzt werden
* Audit-Log schreiben

E. Account Mapping bestätigen

* Source Account auf internes Konto mappen
* PostFinance / True Wealth / Raiffeisen getrennt halten
* Cash und Brokerage nicht vermischen
* Audit-Log schreiben

F. Ignore with note

* Review Item ignorieren
* Notiz Pflicht
* Status ignored
* Audit-Log schreiben

G. Mark resolved

* Nur möglich, wenn Pflichtprobleme gelöst sind
* Status resolved
* Audit-Log schreiben

## 3. Import Readiness Status

Bitte berechne pro Review Item und pro Dry Run Session einen Import-Readiness-Status.

Vorschlag pro Review Item:

* not_ready
* review_needed
* ready_for_import
* ignored
* blocked

Ein Review Item darf nur ready_for_import sein, wenn:

Für Aktien/ETFs:

* source_platform vorhanden
* account mapping vorhanden
* asset_class equity oder etf
* ISIN vorhanden oder Ticker + Exchange explizit bestätigt
* currency vorhanden
* snapshot_date klar oder explizit manuell bestätigt
* Menge vorhanden
* keine blockierenden Quality Flags
* reviewer confirmation vorhanden

Für Cash:

* account mapping vorhanden
* currency vorhanden
* snapshot_date klar oder bestätigt
* Betrag vorhanden
* reviewer confirmation
vorhanden

Für Aggregate/Raiffeisen:

* aggregate_only darf nicht als Instrumentposition importiert werden
* nur Cash-/Kontrollsnapshot, falls eindeutig

## 4. Dry Run Session Management

Bitte baue eine Übersicht für Dry Run Sessions:

* Dry Run ID
* Quelle
* Dateityp
* Erstellungszeitpunkt
* Snapshot Date Status
* Anzahl Review Items
* Anzahl ready_for_import
* Anzahl blocked
* Anzahl ignored
* Anzahl open
* Warnings/Errors

Aktionen vorbereiten:

* Dry Run archivieren
* Dry Run verwerfen
* Dry Run als aktuell markieren
* nur aktuelle Session im Import Wizard priorisieren

Regeln:

* Archivieren/verwerfen löscht keine Audit-Historie.
* Kein produktiver Import durch diese Aktionen.
* Audit-Log für Statusänderung.

## 5. Data Quality Center erweitern

Bitte erweitere das Data Quality Center:

* Anzahl Review Items je Quality Flag
* Anzahl ready_for_import
* Anzahl not_ready
* Anzahl blocked
* Anzahl ignored
* Warnung, wenn eine Quelle 0 ready_for_import hat
* Warnung, wenn Snapshot Date fehlt
* Warnung, wenn viele Items missing_isin/missing_ticker haben
* Link zur Review Queue mit vorgefilterter Ansicht

Buttons:

* Data Quality Recheck
* Resolve Fixed Alerts
* Review Items aktualisieren

Produktive Import-Buttons bleiben deaktiviert.

## 6. Safe Mode / Write Enable

Bitte Safe Mode weiter stärken:

* Global sichtbar:

  * Runtime DB oder Demo DB
  * Read-only oder Write-enabled
  * letzter Backup-Zeitpunkt
  * Git-Safety Status, falls verfügbar
* Default bleibt Read-only.
* Mapping-Aktionen dürfen trotz Read-only nur dann erlaubt sein, wenn sie ausdrücklich als Review-Metadaten-Aktion gelten und keine produktive Portfolio-Position schreiben.
* Produktiver Import bleibt blockiert.

Bitte klar trennen:

* Review-Metadaten schreiben: erlaubt nach Bestätigung
* Portfolio-/Ledger-/Snapshot schreiben: weiterhin blockiert

## 7. Tests

Bitte Tests ergänzen für:

* Review Queue Filter nach Quelle
* Review Queue Filter nach Dry Run ID
* Review Queue Filter nach Quality Flag
* ISIN ergänzen erzeugt Audit
* Ticker/Exchange ergänzen erzeugt Audit
* Name allein bleibt nicht automatisch mapped
* Instrument Mapping mit ISIN kann ready_for_import werden
* Ticker ohne Exchange bleibt review_needed
* Account Mapping Bestätigung erzeugt Audit
* Ignore with note funktioniert
* Ignore ohne Note wird abgelehnt
* Mark resolved nur bei gelösten Pflichtproblemen
* ready_for_import Berechnung für Equity
* ready_for_import Berechnung für ETF
* ready_for_import Berechnung für Cash
* aggregate_only bleibt blockiert für Instrumentimport
* Dry Run archivieren/verwerfen erzeugt Audit
* Data Quality Center zeigt ready/not_ready/blocked/ignored Counts
* produktiver Import bleibt deaktiviert
* keine echten Dateien im Repo
* Git-Safety OK

## 8. Echte Daten

Du darfst die bestehenden echten Runtime Review Items verwenden, um die UI/Funktionen zu prüfen.

Aber:

* keine echten Werte/Mengen im Chat
* keine echten Dateien ins Repo
* keine produktiven Positionen
* keine Ledger-Commits
* keine Cash-Snapshots
* keine positions_snapshot-Writes
* keine echten Reports mit Aktien-/ETF-Zahlen

## 9. Nach Abschluss

Bitte ausführen:

* Compile
* pytest
* Git-Safety
* Git Status

Wenn sauber:

* Commit mit sinnvoller Message
* Push auf main

Bitte berichten:

* neue/geänderte Module
* implementierte Review-Aktionen
* Tests
* Testergebnis
* Git-Safety
* Commit Hash
* Push Status
* Review Item Counts nach Status
* Anzahl ready_for_import je Quelle
* ob produktive Portfolio-Daten unverändert blieben
* nächste Empfehlung

Wichtig:
Ziel von Phase B4 ist, die Review Queue bedienbar zu machen. Noch kein produktiver Aktien-/ETF-/Cash-Import.


Explanation:
**Inspecting code skill**

I need to take action and inspect the code. First, I’m wondering if the skill is already loaded; that’s crucial! The current message is prompting me to load the skill, which implies I might need to check its status. I should verify if everything is set up properly so I can proceed smoothly. Let’s make sure I have all the necessary components ready before moving forward!


[skill_view] name=finance-system-architecture (5,838 chars)


todo

Code-Struktur Review Queue/Dry Run/Data Quality/Audit inspizieren

B4 Schema/Mapping-Actions/Readiness/Session Management implementieren

Dashboard Seiten Filter/Details/Data Quality/Safe Mode erweitern

Tests für B4 ergänzen und produktive Daten-Unverändertheit prüfen

Compile, pytest, Git-Safety, Commit und Push


[read_file] read /home/agent/.hermes/repos/FinanceManager/src/jarvis_finance/imports/broker_mapping.py from line 1 (26,396 chars)


[read_file] read /home/agent/.hermes/repos/FinanceManager/src/jarvis_finance/storage/migrations.py from line 1 (13,534 chars)


[read_file] read /home/agent/.hermes/repos/FinanceManager/src/jarvis_finance/dashboard/data.py from line 1 (20,140 chars)


[read_file] read /home/agent/.hermes/repos/FinanceManager/tests/unit/test_broker_parser_dry_run_pipeline.py from line 1 (10,805 chars)


[read_file] read /home/agent/.hermes/repos/FinanceManager/src/jarvis_finance/audit/log.py from line 1 (1,934 chars)


[read_file] read /home/agent/.hermes/repos/FinanceManager/src/jarvis_finance/dashboard/pages/page_15_manual_review_queue.py from line 1 (1,551 chars)


[read_file] read /home/agent/.hermes/repos/FinanceManager/src/jarvis_finance/dashboard/pages/page_16_data_quality_center.py from line 1 (1,206 chars)


[read_file] read /home/agent/.hermes/repos/FinanceManager/src/jarvis_finance/dashboard/pages/page_14_import_wizard.py from line 1 (2,390 chars)


from pathlib import Path
p=Path('/home/agent/.hermes/repos/FinanceManager/src/jarvis_finance/storage/migrations.py')
s=p.read_text()
s=s.replace('MIGRATION_VERSION = 5\nMIGRATION_NAME = "005_broker_im...[truncated]

Explanation:
**Planning implementation steps**

I need to focus on implementing the necessary changes by writing targeted functions and tests. I’m considering adding schema columns for readiness status, reviewer confirmation, snapshot date confirmation, ticker exchange confirmation, and dry run status, along with designations like is_current and archived. Since compat _add columns seem sufficient, I might bump the migration version to 6. I need to ensure everything is tested and adjust the execute_code for more complex patches carefully to avoid any syntax errors. Let's get on with patching migrations!


Output: migrations patched


[read_file] read /home/agent/.hermes/repos/FinanceManager/src/jarvis_finance/storage/migrations.py from line 190 (4,422 chars)


CREATE TABLE IF NOT EXISTS (instruments|accounts|platforms|audit_log)

Explanation:
**Planning function creation**

I need to create some functions, starting with an easy append in the broker mapping. Then, I have to develop an update function that includes audit capabilities, filters, and readiness checks. I might also need to incorporate accounts and instruments, so I'll inspect the schema to ensure I have all the necessary fields for accounts and instruments. That way, everything aligns well and works smoothly. Let's get this organized!


[read_file] read /home/agent/.hermes/repos/FinanceManager/src/jarvis_finance/storage/schema.py from line 1 (2,781 chars)


def _load_flags(row: Any) -> list[str]:
    try:
        return [str(x) for x in json.loads(row["quality_flags_json"] or "[]")]
    except Exception:
        return []

def _store_flags(flags: list...[truncated]


terminal

set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
cat /tmp/b4_append.py >> src/jarvis_finance/imports/broker_mapping.py
PYTHONPATH=src python -m py_compile src/jarvis_finance/imports/broker_mapping.py src/jarvis_finance/storage/migrations.py


from pathlib import Path
p=Path('/home/agent/.hermes/repos/FinanceManager/src/jarvis_finance/dashboard/data.py')
s=p.read_text()
s=s.replace('def get_broker_dry_runs(conn: Connection, limit: int = 20)...[truncated]


Output: data patched


from __future__ import annotations

from jarvis_finance.dashboard import data
from jarvis_finance.dashboard.components.tables import show_table

PAGE_TITLE = "Manual Review Queue"

QUALITY_FLAGS = [
 ...[truncated]


from __future__ import annotations

from jarvis_finance.dashboard import data
from jarvis_finance.dashboard.components.tables import show_table

PAGE_TITLE = "Data Quality Center"

def render(st, con...[truncated]


patch

st.caption("Phase B2: synthetische Parser-Dry-Runs, Review Items und Quality Flags — kein produktiver Aktien-/ETF-/Cash-Import.")

st.caption("Phase B4: Dry-Run-Sessions, Review Queue und Readiness — kein produktiver Aktien-/ETF-/Cash-Import.")


[patch] replace in /home/agent/.hermes/repos/FinanceManager/src/jarvis_finance/dashboard/pages/page_14_import_wizard.py (965 chars result)


     1|from __future__ import annotations
     2|
     3|from jarvis_finance.storage.database import connect_memory
     4|from jarvis_finance.storage.migrations import apply_migrations, get_schema_version
     5|from jarvis_finance.storage.schema import REQUIRED_TABLES
     6|
     7|
     8|def test_db_schema_can_be_created() -> None:
     9|    conn = connect_memory()
    10|    apply_migrations(conn)
    11|    tables = {row["name"] for row in conn.execute("SELECT name FROM sqlite_master WHERE type='table'")}
    12|    assert set(REQUIRED_TABLES).issubset(tables)
    13|
    14|
    15|def test_schema_version_recorded() -> None:
    16|    conn = connect_memory()
    17|    apply_migrations(conn)
    18|    assert get_schema_version(conn) == 5
    19|
    20|
    21|def test_decimal_sensitive_columns_use_text_affinity() -> None:
    22|    conn = connect_memory()
    23|    apply_migrations(conn)
    24|    tx_cols = {row["name"]: row["type"] for row in conn.execute("PRAGMA table_info(transactions)").fetchall()}
    25|    crypto_cols = {row["name"]: row["type"] for row in conn.execute("PRAGMA table_info(crypto_holdings)").fetchall()}
    26|    instrument_cols = {row["name"] for row in conn.execute("PRAGMA table_info(instruments)").fetchall()}
    27|    assert tx_cols["quantity"].upper() == "TEXT"
    28|    assert tx_cols["fx_rate_to_chf"].upper() == "TEXT"
    29|    assert crypto_cols["quantity"].upper() == "TEXT"
    30|    assert {"position_category", "ter", "distribution_policy", "index_name", "fund_domicile", "benchmark"}.issubset(instrument_cols)
    31|
    32|
    33|def test_broker_bank_mapping_tables_exist_with_required_columns() -> None:
    34|    conn = connect_memory()
    35|    apply_migrations(conn)
    36|    instrument_mapping_cols = {row["name"] for row in conn.execute("PRAGMA table_info(instrument_mappings)").fetchall()}
    37|    account_mapping_cols = {row["name"] for row in conn.execute("PRAGMA table_info(platform_account_mappings)").fetchall()}
    38|    dry_run_cols = {row["name"] for row in conn.execute("PRAGMA table_info(broker_import_dry_runs)").fetchall()}
    39|
    40|    assert {"source_name", "source_platform", "source_label", "normalized_name", "isin", "ticker", "exchange", "currency", "asset_class", "instrument_id", "mapping_status", "confidence", "quality_flags_json"}.issubset(instrument_mapping_cols)
    41|    assert {"source_platform", "source_account_label", "normalized_platform", "normalized_account_name", "internal_platform_id", "internal_account_id", "account_type", "currency", "mapping_status"}.issubset(account_mapping_cols)
    42|    assert {"source_platform", "source_file_type", "source_filename_hash", "detected_snapshot_date", "snapshot_date_status", "candidate_positions", "candidate_cash_rows", "mapped_positions", "blocked_positions", "quality_flags_json", "summary_json"}.issubset(dry_run_cols)
    43|    review_cols = {row["name"] for row in conn.execute("PRAGMA table_info(broker_import_review_items)").fetchall()}
    44|    assert {"review_item_id", "dry_run_id", "source_platform", "source_row_ref", "row_hash", "source_label", "normalized_name", "detected_asset_class", "detected_currency", "quality_flags_json", "review_status"}.issubset(review_cols)
    45|


--- a//home/agent/.hermes/repos/FinanceManager/tests/unit/test_schema.py
+++ b//home/agent/.hermes/repos/FinanceManager/tests/unit/test_schema.py
@@ -15,7 +15,7 @@
 def test_schema_version_recorded() -> None:
     conn = connect_memory()
     apply_migrations(conn)
-    assert get_schema_version(conn) == 5
+    assert get_schema_version(conn) == 6

 def test_decimal_sensitive_columns_use_text_affinity() -> None:


    assert {"source_platform", "source_file_type", "source_filename_hash", "detected_snapshot_date", "snapshot_date_status", "candidate_positions", "candidate_cash_rows", "mapped_positions", "blocked_positions", "quality_flags_json", "summary_json", "session_status", "is_current"}.issubset(dry_run_cols)
    review_cols = {row["name"] for row in conn.execute("PRAGMA table_info(broker_import_review_items)").fetchall()}
    assert {"review_item_id", "dry_run_id", "source_platform", "source_row_ref", "row_hash", "source_label", "normalized_name", "detected_asset_class", "detected_currency", "quality_flags_json", "review_status", "import_readiness_status", "reviewer_confirmed", "snapshot_date_confirmed", "ticker_exchange_confirmed", "account_mapping_status"}.issubset(review_cols)

    assert {"source_platform", "source_file_type", "source_filename_hash", "detected_snapshot_date", "snapshot_date_status", "candidate_positions", "candidate_cash_rows", "mapped_positions", "blocked_positions", "quality_flags_json", "summary_json"}.issubset(dry_run_cols)
    review_cols = {row["name"] for row in conn.execute("PRAGMA table_info(broker_import_review_items)").fetchall()}
    assert {"review_item_id", "dry_run_id", "source_platform", "source_row_ref", "row_hash", "source_label", "normalized_name", "detected_asset_class", "detected_currency", "quality_flags_json", "review_status"}.issubset(review_cols)


--- a//home/agent/.hermes/repos/FinanceManager/tests/unit/test_schema.py
+++ b//home/agent/.hermes/repos/FinanceManager/tests/unit/test_schema.py
@@ -39,6 +39,6 @@

     assert {"source_name", "source_platform", "source_label", "normalized_name", "isin", "ticker", "exchange", "currency", "asset_class", "instrument_id", "mapping_status", "confidence", "quality_flags_json"}.issubset(instrument_mapping_cols)
     assert {"source_platform", "source_account_label", "normalized_platform", "normalized_account_name", "internal_platform_id", "internal_account_id", "account_type", "currency", "mapping_status"}.issubset(account_mapping_cols)
-    assert {"source_platform", "source_file_type", "source_filename_hash", "detected_snapshot_date", "snapshot_date_status", "candidate_positions", "candidate_cash_rows", "mapped_positions", "blocked_positions", "quality_flags_json", "summary_json"}.issubset(dry_run_cols)
+    assert {"source_platform", "source_file_type", "source_filename_hash", "detected_snapshot_date", "snapshot_date_status", "candidate_positions", "candidate_cash_rows", "mapped_positions", "blocked_positions", "quality_flags_json", "summary_json", "session_status", "is_current"}.issubset(dry_run_cols)
     review_cols = {row["name"] for row in conn.execute("PRAGMA table_info(broker_import_review_items)").fetchall()}
-    assert {"review_item_id", "dry_run_id", "source_platform", "source_row_ref", "row_hash", "source_label", "normalized_name", "detected_asset_class", "detected_currency", "quality_flags_json", "review_status"}.issubset(review_cols)
+    assert {"review_item_id", "dry_run_id", "source_platform", "source_row_ref", "row_hash", "source_label", "normalized_name", "detected_asset_class", "detected_currency", "quality_flags_json", "review_status", "import_readiness_status", "reviewer_confirmed", "snapshot_date_confirmed", "ticker_exchange_confirmed", "account_mapping_status"}.issubset(review_cols)


from jarvis_finance.imports.broker_mapping import assert_write_enabled, confirm_review_item_mapping, get_broker_review_items, run_broker_import_dry_run

from jarvis_finance.imports.broker_mapping import (
    assert_productive_import_disabled,
    assert_write_enabled,
    confirm_review_item_account_mapping,
    confirm_review_item_instrument_mapping,
    confirm_review_item_snapshot_date,
    confirm_review_item_mapping,
    create_broker_import_review_item,
    get_broker_review_items,
    get_dry_run_sessions,
    ignore_review_item,
    mark_review_item_resolved,
    run_broker_import_dry_run,
    update_dry_run_session_status,
    update_review_item_isin,
    update_review_item_ticker_exchange,
)

Explanation:
**Updating import functions**

I need to append some tests, and I think a direct call to create_review_item at a lower level would be easier. So, I should import the necessary functions for that. Right now, my import line isn’t quite enough and needs to expand. It's a good opportunity to double-check all the imports to make sure I have everything I need for the tests to run smoothly.


--- a//home/agent/.hermes/repos/FinanceManager/tests/unit/test_broker_parser_dry_run_pipeline.py
+++ b//home/agent/.hermes/repos/FinanceManager/tests/unit/test_broker_parser_dry_run_pipeline.py
@@ -4,7 +4,23 @@
 from pathlib import Path

 from jarvis_finance.dashboard import data as dashboard_data
-from jarvis_finance.imports.broker_mapping import assert_write_enabled, confirm_review_item_mapping, get_broker_review_items, run_broker_import_dry_run
+from jarvis_finance.imports.broker_mapping import (
+    assert_productive_import_disabled,
+    assert_write_enabled,
+    confirm_review_item_account_mapping,
+    confirm_review_item_instrument_mapping,
+    confirm_review_item_snapshot_date,
+    confirm_review_item_mapping,
+    create_broker_import_review_item,
+    get_broker_review_items,
+    get_dry_run_sessions,
+    ignore_review_item,
+    mark_review_item_resolved,
+    run_broker_import_dry_run,
+    update_dry_run_session_status,
+    update_review_item_isin,
+    update_review_item_ticker_exchange,
+)
 from jarvis_finance.imports.broker_parsers import parse_postfinance_docx, parse_raiffeisen_xlsx, parse_true_wealth_docx
 from jarvis_finance.storage.database import connect_memory
 from jarvis_finance.storage.migrations import apply_migrations, utc_now


def seed_instrument(c, *, instrument_id='inst-1', asset_class='etf', isin='CH0000000001', ticker='METF', exchange='SIX', currency='CHF'):
    c.execute("INSERT INTO instruments(instrument_id, asset_class, name, ticker, isin, exchange, currency, created_at) VALUES (?,?,?,?,?,?,?,?)", (instrument_id, asset_class, 'Mapped ETF', ticker, isin, exchange, currency, utc_now()))

def seed_accounts(c):
    c.execute("INSERT INTO platforms(platform_id, name, platform_type, created_at) VALUES ('pf','PostFinance','broker',?)", (utc_now(),))
    c.execute("INSERT INTO accounts(account_id, platform_id, account_name, account_type, currency, created_at) VALUES ('acct-broker','pf','Brokerage','brokerage','CHF',?)", (utc_now(),))
    c.execute("INSERT INTO accounts(account_id, platform_id, account_name, account_type, currency, created_at) VALUES ('acct-cash','pf','Cash','cash','CHF',?)", (utc_now(),))

def seed_review_item(c, *, source='PostFinance', asset_class='etf', currency='CHF', flags=None, quantity=True, market_value=True, status='open'):
    dry = run_broker_import_dry_run(c, parse_postfinance_docx.__globals__['ParsedBrokerFile'] if False else None, source_filename='x') if False else None
    c.execute("INSERT INTO broker_import_dry_runs(dry_run_id, source_name, source_platform, source_file_label, source_file_type, source_hash, source_filename_hash, detected_sections_json, rows_total, quality_flags_json, summary_json, created_at, snapshot_date_status) VALUES ('dry-1', ?, ?, '[redacted]', 'docx', 'h', 'h', '[]', 1, '{}', '{}', ?, 'missing')", (source, source, utc_now()))
    return create_broker_import_review_item(c, dry_run_id='dry-1', source_platform=source, source_file_type='docx', source_row_ref='row-1', source_label='Synthetic Label', detected_asset_class=asset_class, detected_currency=currency, detected_quantity_present=quantity, detected_market_value_present=market_value, quality_flags=flags or ['missing_isin', 'missing_ticker', 'snapshot_only', 'cost_basis_uncertain'], review_status=status)

def seed_instrument(c):
    c.execute("INSERT INTO instruments(instrument_id, asset_class, name, ticker, isin, exchange, currency, created_at) VALUES ('inst-1','etf','Mapped ETF','METF','CH0000000001','SIX','CHF',?)", (utc_now(),))


--- a//home/agent/.hermes/repos/FinanceManager/tests/unit/test_broker_parser_dry_run_pipeline.py
+++ b//home/agent/.hermes/repos/FinanceManager/tests/unit/test_broker_parser_dry_run_pipeline.py
@@ -63,8 +63,20 @@
     return c

-def seed_instrument(c):
-    c.execute("INSERT INTO instruments(instrument_id, asset_class, name, ticker, isin, exchange, currency, created_at) VALUES ('inst-1','etf','Mapped ETF','METF','CH0000000001','SIX','CHF',?)", (utc_now(),))
+def seed_instrument(c, *, instrument_id='inst-1', asset_class='etf', isin='CH0000000001', ticker='METF', exchange='SIX', currency='CHF'):
+    c.execute("INSERT INTO instruments(instrument_id, asset_class, name, ticker, isin, exchange, currency, created_at) VALUES (?,?,?,?,?,?,?,?)", (instrument_id, asset_class, 'Mapped ETF', ticker, isin, exchange, currency, utc_now()))
+
+
+def seed_accounts(c):
+    c.execute("INSERT INTO platforms(platform_id, name, platform_type, created_at) VALUES ('pf','PostFinance','broker',?)", (utc_now(),))
+    c.execute("INSERT INTO accounts(account_id, platform_id, account_name, account_type, currency, created_at) VALUES ('acct-broker','pf','Brokerage','brokerage','CHF',?)", (utc_now(),))
+    c.execute("INSERT INTO accounts(account_id, platform_id, account_name, account_type, currency, created_at) VALUES ('acct-cash','pf','Cash','cash','CHF',?)", (utc_now(),))
+
+
+def seed_review_item(c, *, source='PostFinance', asset_class='etf', currency='CHF', flags=None, quantity=True, market_value=True, status='open'):
+    dry = run_broker_import_dry_run(c, parse_postfinance_docx.__globals__['ParsedBrokerFile'] if False else None, source_filename='x') if False else None
+    c.execute("INSERT INTO broker_import_dry_runs(dry_run_id, source_name, source_platform, source_file_label, source_file_type, source_hash, source_filename_hash, detected_sections_json, rows_total, quality_flags_json, summary_json, created_at, snapshot_date_status) VALUES ('dry-1', ?, ?, '[redacted]', 'docx', 'h', 'h', '[]', 1, '{}', '{}', ?, 'missing')", (source, source, utc_now()))
+    return create_broker_import_review_item(c, dry_run_id='dry-1', source_platform=source, source_file_type='docx', source_row_ref='row-1', source_label='Synthetic Label', detected_asset_class=asset_class, detected_currency=currency, detected_quantity_present=quantity, detected_market_value_present=market_value, quality_flags=flags or ['missing_isin', 'missing_ticker', 'snapshot_only', 'cost_basis_uncertain'], review_status=status)

 def test_synthetic_postfinance_parser_recognizes_candidates_and_quality_flags(tmp_path: Path) -> None:


def seed_review_item(c, *, source='PostFinance', asset_class='etf', currency='CHF', flags=None, quantity=True, market_value=True, status='open'):
    c.execute("INSERT INTO broker_import_dry_runs(dry_run_id, source_name, source_platform, source_file_label, source_file_type, source_hash, source_filename_hash, detected_sections_json, rows_total, quality_flags_json, summary_json, created_at, snapshot_date_status) VALUES ('dry-1', ?, ?, '[redacted]', 'docx', 'h', 'h', '[]', 1, '{}', '{}', ?, 'missing')", (source, source, utc_now()))

def seed_review_item(c, *, source='PostFinance', asset_class='etf', currency='CHF', flags=None, quantity=True, market_value=True, status='open'):
    dry = run_broker_import_dry_run(c, parse_postfinance_docx.__globals__['ParsedBrokerFile'] if False else None, source_filename='x') if False else None
    c.execute("INSERT INTO broker_import_dry_runs(dry_run_id, source_name, source_platform, source_file_label, source_file_type, source_hash, source_filename_hash, detected_sections_json, rows_total, quality_flags_json, summary_json, created_at, snapshot_date_status) VALUES ('dry-1', ?, ?, '[redacted]', 'docx', 'h', 'h', '[]', 1, '{}', '{}', ?, 'missing')", (source, source, utc_now()))


--- a//home/agent/.hermes/repos/FinanceManager/tests/unit/test_broker_parser_dry_run_pipeline.py
+++ b//home/agent/.hermes/repos/FinanceManager/tests/unit/test_broker_parser_dry_run_pipeline.py
@@ -74,7 +74,6 @@

 def seed_review_item(c, *, source='PostFinance', asset_class='etf', currency='CHF', flags=None, quantity=True, market_value=True, status='open'):
-    dry = run_broker_import_dry_run(c, parse_postfinance_docx.__globals__['ParsedBrokerFile'] if False else None, source_filename='x') if False else None
     c.execute("INSERT INTO broker_import_dry_runs(dry_run_id, source_name, source_platform, source_file_label, source_file_type, source_hash, source_filename_hash, detected_sections_json, rows_total, quality_flags_json, summary_json, created_at, snapshot_date_status) VALUES ('dry-1', ?, ?, '[redacted]', 'docx', 'h', 'h', '[]', 1, '{}', '{}', ?, 'missing')", (source, source, utc_now()))
     return create_broker_import_review_item(c, dry_run_id='dry-1', source_platform=source, source_file_type='docx', source_row_ref='row-1', source_label='Synthetic Label', detected_asset_class=asset_class, detected_currency=currency, detected_quantity_present=quantity, detected_market_value_present=market_value, quality_flags=flags or ['missing_isin', 'missing_ticker', 'snapshot_only', 'cost_basis_uncertain'], review_status=status)


def test_b4_review_queue_filters_by_source_dry_run_and_quality_flag(tmp_path: Path) -> None:
    c = conn()
    p1 = tmp_path / "pf.docx"; _docx(p1, [["Produkt", "Menge", "Währung"], ["ETF A", "Menge", "CHF"]])
    p2 = tmp_path / "tw.docx"; _docx(p2, [["Position", "Währung"], ["ETF B", "USD"]])
    s1 = run_broker_import_dry_run(c, parse_postfinance_docx(p1), source_filename=p1.name)
    s2 = run_broker_import_dry_run(c, parse_true_wealth_docx(p2), source_filename=p2.name)
    assert len(get_broker_review_items(c, source_platform="PostFinance")) == 1
    assert len(get_broker_review_items(c, dry_run_id=s2["dry_run_id"])) == 1
    assert len(get_broker_review_items(c, quality_flag="missing_fx")) == 1

def test_b4_isin_ticker_exchange_updates_write_audit_and_name_only_not_mapped() -> None:
    c = conn(); item = seed_review_item(c)
    update_review_item_isin(c, review_item_id=item, isin="CH0000000001", note="synthetic isin")
    update_review_item_ticker_exchange(c, review_item_id=item, ticker="METF", note="synthetic ticker")
    row = c.execute("SELECT * FROM broker_import_review_items WHERE review_item_id=?", (item,)).fetchone()
    assert row["isin"] == "CH0000000001"
    assert row["ticker"] == "METF"
    assert "missing_isin" not in row["quality_flags_json"]
    assert row["review_status"] == "open"
    assert c.execute("SELECT COUNT(*) AS n FROM audit_log WHERE entity_id=?", (item,)).fetchone()["n"] == 2

def test_b4_ticker_without_exchange_stays_review_needed() -> None:
    c = conn(); item = seed_review_item(c)
    update_review_item_ticker_exchange(c, review_item_id=item, ticker="METF", note="ticker only")
    row = c.execute("SELECT import_readiness_status, quality_flags_json FROM broker_import_review_items WHERE review_item_id=?", (item,)).fetchone()
    assert row["import_readiness_status"] in {"not_ready", "review_needed"}
    assert "ticker_without_exchange" in row["quality_flags_json"]

def test_b4_instrument_mapping_with_isin_can_be_ready_for_import_for_equity() -> None:
    c = conn(); seed_instrument(c, asset_class="equity"); seed_accounts(c); item = seed_review_item(c, asset_class="equity")
    update_review_item_isin(c, review_item_id=item, isin="CH0000000001", note="isin")
    confirm_review_item_account_mapping(c, review_item_id=item, account_id="acct-broker", note="account")
    confirm_review_item_snapshot_date(c, review_item_id=item, note="snapshot confirmed")
    confirm_review_item_instrument_mapping(c, review_item_id=item, instrument_id="inst-1", note="instrument")
    row = c.execute("SELECT import_readiness_status FROM broker_import_review_items WHERE review_item_id=?", (item,)).fetchone()
    assert row["import_readiness_status"] == "ready_for_import"

def test_b4_ready_for_import_for_etf_and_account_mapping_audit() -> None:
    c = conn(); seed_instrument(c); seed_accounts(c); item = seed_review_item(c, asset_class="etf")
    update_review_item_isin(c, review_item_id=item, isin="CH0000000001", note="isin")
    audit = confirm_review_item_account_mapping(c, review_item_id=item, account_id="acct-broker", note="account")
    confirm_review_item_snapshot_date(c, review_item_id=item, note="snapshot")
    confirm_review_item_instrument_mapping(c, review_item_id=item, instrument_id="inst-1", note="instrument")
    assert audit
    assert c.execute("SELECT import_readiness_status FROM broker_import_review_items WHERE review_item_id=?", (item,)).fetchone()["import_readiness_status"] == "ready_for_import"

def test_b4_ready_for_import_for_cash() -> None:
    c = conn(); seed_accounts(c); item = seed_review_item(c, asset_class="cash", flags=["cash_snapshot_candidate"], quantity=False, market_value=True)
    confirm_review_item_account_mapping(c, review_item_id=item, account_id="acct-cash", note="cash account")
    confirm_review_item_snapshot_date(c, review_item_id=item, note="snapshot")
    # cash has no instrument mapping; reviewer confirmation is modelled by explicit metadata confirmation here
    c.execute("UPDATE broker_import_review_items SET reviewer_confirmed=1 WHERE review_item_id=?", (item,))
    from jarvis_finance.imports.broker_mapping import refresh_review_item_readiness
    assert refresh_review_item_readiness(c, item) == "ready_for_import"

def test_b4_ignore_requires_note_and_mark_resolved_requires_ready() -> None:
    c = conn(); item = seed_review_item(c)
    try:
        ignore_review_item(c, review_item_id=item, note="")
    except ValueError:
        pass
    else:
        raise AssertionError("ignore without note accepted")
    ignored_audit = ignore_review_item(c, review_item_id=item, note="synthetic ignore")
    assert ignored_audit
    item2 = seed_review_item(c, source="True Wealth")
    try:
        mark_review_item_resolved(c, review_item_id=item2, note="too early")
    except ValueError:
        pass
    else:
        raise AssertionError("resolved before ready accepted")

def test_b4_aggregate_only_remains_blocked_for_instrument_import() -> None:
    c = conn(); item = seed_review_item(c, source="Raiffeisen", asset_class="other", flags=["aggregate_only", "missing_instrument_details"], status="blocked")
    row = c.execute("SELECT import_readiness_status, review_status FROM broker_import_review_items WHERE review_item_id=?", (item,)).fetchone()
    from jarvis_finance.imports.broker_mapping import refresh_review_item_readiness
    assert refresh_review_item_readiness(c, item) == "blocked"

def test_b4_dry_run_session_archive_discard_current_writes_audit(tmp_path: Path) -> None:
    c = conn()
    p = tmp_path / "pf.docx"; _docx(p, [["Produkt", "Menge", "Währung"], ["ETF A", "Menge", "CHF"]])
    summary = run_broker_import_dry_run(c, parse_postfinance_docx(p), source_filename=p.name)
    update_dry_run_session_status(c, dry_run_id=summary["dry_run_id"], action="mark_current", note="current")
    update_dry_run_session_status(c, dry_run_id=summary["dry_run_id"], action="archive", note="archive")
    sessions = get_dry_run_sessions(c)
    assert sessions[0]["session_status"] == "archived"
    assert c.execute("SELECT COUNT(*) AS n FROM audit_log WHERE entity_id=?", (summary["dry_run_id"],)).fetchone()["n"] == 2

def test_b4_data_quality_readiness_counts_and_productive_import_disabled() -> None:
    c = conn(); item = seed_review_item(c)
    rows = {r["check"]: r["count"] for r in dashboard_data.get_data_quality(c)}
    assert "Review Readiness: not_ready" in rows
    assert assert_productive_import_disabled() is True
    assert c.execute("SELECT COUNT(*) AS n FROM positions_snapshot").fetchone()["n"] == 0

Explanation:
**Appending tests and issues**

I'm considering how to append tests. I need to think about the seed_review duplicate dry-1 issue, especially if there are multiple entries in the same connection. For the filters, maybe I should use the run function in conjunction with files. It seems like appending everything could help streamline the process. Alright, I’ll keep these details in mind as I move forward!


terminal

cd /home/agent/.hermes/repos/FinanceManager && cat /tmp/b4_tests_append.py >> tests/unit/test_broker_parser_dry_run_pipeline.py && PYTHONPATH=src pytest tests/unit/test_broker_parser_dry_run_pipeline.py tests/unit/test_schema.py -q


Output:
.................F.......                                                [100%]
=================================== FAILURES ===================================
________ test_b4_ignore_requires_note_and_mark_resolved_requires_ready _________

    def test_b4_ignore_requires_note_and_mark_resolved_requires_ready() -> None:
        c = conn(); item = seed_review_item(c)
        try:
            ignore_review_item(c, review_item_id=item, note="")
        except ValueError:
            pass
        else:
            raise AssertionError("ignore without note accepted")
        ignored_audit = ignore_review_item(c, review_item_id=item, note="synthetic ignore")
        assert ignored_audit
>       item2 = seed_review_item(c, source="True Wealth")
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/unit/test_broker_parser_dry_run_pipeline.py:270:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

c = <sqlite3.Connection object at 0x7697615a58a0>

    def seed_review_item(c, *, source='PostFinance', asset_class='etf', currency='CHF', flags=None, quantity=True, market_value=True, status='open'):
>       c.execute("INSERT INTO broker_import_dry_runs(dry_run_id, source_name, source_platform, source_file_label, source_file_type, source_hash, source_filename_hash, detected_sections_json, rows_total, quality_flags_json, summary_json, created_at, snapshot_date_status) VALUES ('dry-1', ?, ?, '[redacted]', 'docx', 'h', 'h', '[]', 1, '{}', '{}', ?, 'missing')", (source, source, utc_now()))
E       sqlite3.IntegrityError: UNIQUE constraint failed: broker_import_dry_runs.dry_run_id

tests/unit/test_broker_parser_dry_run_pipeline.py:77: IntegrityError
=========================== short test summary info ============================
FAILED tests/unit/test_broker_parser_dry_run_pipeline.py::test_b4_ignore_requires_note_and_mark_resolved_requires_ready
1 failed, 24 passed in 0.26s


patch

import zipfile
import uuid
from pathlib import Path


--- a//home/agent/.hermes/repos/FinanceManager/tests/unit/test_broker_parser_dry_run_pipeline.py
+++ b//home/agent/.hermes/repos/FinanceManager/tests/unit/test_broker_parser_dry_run_pipeline.py
@@ -1,6 +1,7 @@
 from __future__ import annotations

 import zipfile
+import uuid
 from pathlib import Path

 from jarvis_finance.dashboard import data as dashboard_data

/home/agent/.hermes/repos/FinanceManager/tests/unit/test_broker_parser_dry_run_pipeline.py was modified since you last read it on disk (external edit or unrecorded writer). Re-read the file before writing.


def seed_review_item(c, *, source='PostFinance', asset_class='etf', currency='CHF', flags=None, quantity=True, market_value=True, status='open'):
    dry_id = f"dry-{uuid.uuid4()}"
    c.execute("INSERT INTO broker_import_dry_runs(dry_run_id, source_name, source_platform, source_file_label, source_file_type, source_hash, source_filename_hash, detected_sections_json, rows_total, quality_flags_json, summary_json, created_at, snapshot_date_status) VALUES (?, ?, ?, '[redacted]', 'docx', 'h', 'h', '[]', 1, '{}', '{}', ?, 'missing')", (dry_id, source, source, utc_now()))
    return create_broker_import_review_item(c, dry_run_id=dry_id, source_platform=source, source_file_type='docx', source_row_ref='row-1', source_label='Synthetic Label', detected_asset_class=asset_class, detected_currency=currency, detected_quantity_present=quantity, detected_market_value_present=market_value, quality_flags=flags or ['missing_isin', 'missing_ticker', 'snapshot_only', 'cost_basis_uncertain'], review_status=status)

def seed_review_item(c, *, source='PostFinance', asset_class='etf', currency='CHF', flags=None, quantity=True, market_value=True, status='open'):
    c.execute("INSERT INTO broker_import_dry_runs(dry_run_id, source_name, source_platform, source_file_label, source_file_type, source_hash, source_filename_hash, detected_sections_json, rows_total, quality_flags_json, summary_json, created_at, snapshot_date_status) VALUES ('dry-1', ?, ?, '[redacted]', 'docx', 'h', 'h', '[]', 1, '{}', '{}', ?, 'missing')", (source, source, utc_now()))
    return create_broker_import_review_item(c, dry_run_id='dry-1', source_platform=source, source_file_type='docx', source_row_ref='row-1', source_label='Synthetic Label', detected_asset_class=asset_class, detected_currency=currency, detected_quantity_present=quantity, detected_market_value_present=market_value, quality_flags=flags or ['missing_isin', 'missing_ticker', 'snapshot_only', 'cost_basis_uncertain'], review_status=status)


--- a//home/agent/.hermes/repos/FinanceManager/tests/unit/test_broker_parser_dry_run_pipeline.py
+++ b//home/agent/.hermes/repos/FinanceManager/tests/unit/test_broker_parser_dry_run_pipeline.py
@@ -75,8 +75,9 @@

 def seed_review_item(c, *, source='PostFinance', asset_class='etf', currency='CHF', flags=None, quantity=True, market_value=True, status='open'):
-    c.execute("INSERT INTO broker_import_dry_runs(dry_run_id, source_name, source_platform, source_file_label, source_file_type, source_hash, source_filename_hash, detected_sections_json, rows_total, quality_flags_json, summary_json, created_at, snapshot_date_status) VALUES ('dry-1', ?, ?, '[redacted]', 'docx', 'h', 'h', '[]', 1, '{}', '{}', ?, 'missing')", (source, source, utc_now()))
-    return create_broker_import_review_item(c, dry_run_id='dry-1', source_platform=source, source_file_type='docx', source_row_ref='row-1', source_label='Synthetic Label', detected_asset_class=asset_class, detected_currency=currency, detected_quantity_present=quantity, detected_market_value_present=market_value, quality_flags=flags or ['missing_isin', 'missing_ticker', 'snapshot_only', 'cost_basis_uncertain'], review_status=status)
+    dry_id = f"dry-{uuid.uuid4()}"
+    c.execute("INSERT INTO broker_import_dry_runs(dry_run_id, source_name, source_platform, source_file_label, source_file_type, source_hash, source_filename_hash, detected_sections_json, rows_total, quality_flags_json, summary_json, created_at, snapshot_date_status) VALUES (?, ?, ?, '[redacted]', 'docx', 'h', 'h', '[]', 1, '{}', '{}', ?, 'missing')", (dry_id, source, source, utc_now()))
+    return create_broker_import_review_item(c, dry_run_id=dry_id, source_platform=source, source_file_type='docx', source_row_ref='row-1', source_label='Synthetic Label', detected_asset_class=asset_class, detected_currency=currency, detected_quantity_present=quantity, detected_market_value_present=market_value, quality_flags=flags or ['missing_isin', 'missing_ticker', 'snapshot_only', 'cost_basis_uncertain'], review_status=status)

 def test_synthetic_postfinance_parser_recognizes_candidates_and_quality_flags(tmp_path: Path) -> None:


terminal

cd /home/agent/.hermes/repos/FinanceManager && PYTHONPATH=src pytest tests/unit/test_broker_parser_dry_run_pipeline.py tests/unit/test_schema.py -q


Output:
.........................                                                [100%]
25 passed in 0.22s


todo

Code-Struktur Review Queue/Dry Run/Data Quality/Audit inspizieren

B4 Schema/Mapping-Actions/Readiness/Session Management implementieren

Dashboard Seiten Filter/Details/Data Quality/Safe Mode erweitern

Tests für B4 ergänzen und produktive Daten-Unverändertheit prüfen

Explanation:
**Testing migration issues**

I need to test whether the old `confirm_review_item_mapping` is failing due to new columns. It seems `create_review_item` doesn't set readiness, which might affect aggregate tests. I should verify that the runtime applies migration and check status counts. There's also a chance the migration version is bumped, but the existing schema lacks session columns. I have to run the migration, but first, I need to compile everything to ensure readiness.


Compile, pytest, Git-Safety, Commit und Push


terminal

set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
PYTHONPATH=src python -m jarvis_finance.cli.main migrate
PYTHONPATH=src python - <<'PY'
import json
from jarvis_finance.config.settings import load_settings
from jarvis_finance.storage.database import connect
from jarvis_finance.storage.migrations import apply_migrations
from jarvis_finance.imports.broker_mapping import refresh_review_item_readiness, get_ready_for_import_by_source
conn=connect(load_settings().db_path); apply_migrations(conn)
for row in conn.execute('SELECT review_item_id FROM broker_import_review_items').fetchall():
    refresh_review_item_readiness(conn, row['review_item_id'])
conn.commit()
status_counts={}
for row in conn.execute('SELECT source_platform, review_status, import_readiness_status, COUNT(*) AS n FROM broker_import_review_items GROUP BY source_platform, review_status, import_readiness_status').fetchall():
    status_counts.setdefault(row['source_platform'], []).append({'status':row['review_status'],'readiness':row['import_readiness_status'],'count':row['n']})
productive={t: conn.execute(f'SELECT COUNT(*) AS n FROM {t}').fetchone()['n'] for t in ['positions_snapshot','transactions']}
print(json.dumps({'status_counts':status_counts,'ready_by_source':get_ready_for_import_by_source(conn),'productive_counts':productive}, sort_keys=True))
PY


Output:
SCHEMA_VERSION=6
{"productive_counts": {"positions_snapshot": 0, "transactions": 0}, "ready_by_source": [{"ready_for_import": "0", "source_platform": "PostFinance", "total": "34"}, {"ready_for_import": "0", "source_platform": "Raiffeisen", "total": "7"}, {"ready_for_import": "0", "source_platform": "True Wealth", "total": "18"}], "status_counts": {"PostFinance": [{"count": 33, "readiness": "not_ready", "status": "open"}, {"count": 1, "readiness": "review_needed", "status": "open"}], "Raiffeisen": [{"count": 4, "readiness": "blocked", "status": "blocked"}, {"count": 3, "readiness": "review_needed", "status": "open"}], "True Wealth": [{"count": 17, "readiness": "not_ready", "status": "open"}, {"count": 1, "readiness": "review_needed", "status": "open"}]}}


Output:
.........F.............................................................. [ 46%]
........................................................................ [ 92%]
...........                                                              [100%]
=================================== FAILURES ===================================
__ test_import_wizard_manual_review_and_data_quality_pages_import_and_render ___

    def test_import_wizard_manual_review_and_data_quality_pages_import_and_render() -> None:
        c = conn()
        create_instrument_mapping(c, source_platform="PostFinance", source_label="Unknown ETF", asset_class="etf", currency="USD")
        st = FakeStreamlit()
        for module in [page_14_import_wizard, page_15_manual_review_queue, page_16_data_quality_center]:
>           module.render(st, c)

tests/unit/test_broker_mapping_import_wizard.py:122:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

st = <test_broker_mapping_import_wizard.FakeStreamlit object at 0x7d8e946e7390>
conn = <sqlite3.Connection object at 0x7d8e949ccc70>

    def render(st, conn) -> None:
        st.title("Manual Review Queue")
        st.caption("Phase B4: Runtime-Review-Metadaten bearbeiten; Portfolio-/Ledger-/Snapshot-Writes bleiben blockiert.")

        sessions = data.get_broker_dry_runs(conn, limit=100)
        dry_run_ids = [s["dry_run_id"] for s in sessions if s.get("dry_run_id")]

        st.subheader("Filter")
        c1, c2, c3 = st.columns(3)
        with c1:
            source = _none_if_all(st.selectbox("Quelle", ["Alle", "PostFinance", "True Wealth", "Raiffeisen"]))
            status = _none_if_all(st.selectbox("Status", ["Alle", "open", "blocked", "mapped", "ignored", "resolved"]))
            asset_class = _none_if_all(st.selectbox("Assetklasse", ["Alle", "equity", "etf", "cash", "other"]))
        with c2:
            dry_run_id = _none_if_all(st.selectbox("Dry Run Session", ["Alle", *dry_run_ids]))
            quality_flag = _none_if_all(st.selectbox("Quality Flag", ["Alle", *QUALITY_FLAGS]))
>           currency = st.text_input("Währung", value="").strip().upper() or None
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E           AttributeError: 'NoneType' object has no attribute 'strip'

src/jarvis_finance/dashboard/pages/page_15_manual_review_queue.py:35: AttributeError
=========================== short test summary info ============================
FAILED tests/unit/test_broker_mapping_import_wizard.py::test_import_wizard_manual_review_and_data_quality_pages_import_and_render
1 failed, 154 passed in 5.00s


patch

        currency_value = st.text_input("Währung", value="")
        currency = (currency_value or "").strip().upper() or None

currency = st.text_input("Währung", value="").strip().upper() or None


--- a//home/agent/.hermes/repos/FinanceManager/src/jarvis_finance/dashboard/pages/page_15_manual_review_queue.py
+++ b//home/agent/.hermes/repos/FinanceManager/src/jarvis_finance/dashboard/pages/page_15_manual_review_queue.py
@@ -32,7 +32,8 @@
     with c2:
         dry_run_id = _none_if_all(st.selectbox("Dry Run Session", ["Alle", *dry_run_ids]))
         quality_flag = _none_if_all(st.selectbox("Quality Flag", ["Alle", *QUALITY_FLAGS]))
-        currency = st.text_input("Währung", value="").strip().upper() or None
+        currency_value = st.text_input("Währung", value="")
+        currency = (currency_value or "").strip().upper() or None
     with c3:
         account_mapping_status = _none_if_all(st.selectbox("Account Mapping", ["Alle", "missing", "mapped"]))
         readiness = _none_if_all(st.selectbox("Import Readiness", ["Alle", "not_ready", "review_needed", "ready_for_import", "ignored", "blocked"]))


Output:
........................................................................ [ 46%]
........................................................................ [ 92%]
...........                                                              [100%]
155 passed in 4.87s
GIT_SAFETY_OK
## main...origin/main
 M src/jarvis_finance/dashboard/data.py
 M src/jarvis_finance/dashboard/pages/page_14_import_wizard.py
 M src/jarvis_finance/dashboard/pages/page_15_manual_review_queue.py
 M src/jarvis_finance/dashboard/pages/page_16_data_quality_center.py
 M src/jarvis_finance/imports/broker_mapping.py
 M src/jarvis_finance/storage/migrations.py
 M tests/unit/test_broker_parser_dry_run_pipeline.py
 M tests/unit/test_schema.py


terminal

set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
git diff --stat
git add src/jarvis_finance/dashboard/data.py src/jarvis_finance/dashboard/pages/page_14_import_wizard.py src/jarvis_finance/dashboard/pages/page_15_manual_review_queue.py src/jarvis_finance/dashboard/pages/page_16_data_quality_center.py src/jarvis_finance/imports/broker_mapping.py src/jarvis_finance/storage/migrations.py tests/unit/test_broker_parser_dry_run_pipeline.py tests/unit/test_schema.py
git commit -m "feat: harden broker review queue mapping workflow"
PYTHONPATH=src python -m compileall -q src tests
PYTHONPATH=src pytest -q
rm -rf .pytest_cache src/jarvis_finance/**/__pycache__ tests/**/__pycache__
PYTHONPATH=src python -m jarvis_finance.cli.main git-safety-scan .
git status --short --branch

Explanation:
**Running git commands**

I’m thinking about running `git diff` to compare changes, but first, I need to finalize some counts based on the latest runtime updates. It’s interesting to consider whether I actually need real files for this. I want to ensure safety is up to par before I commit these changes. Once that’s settled, I’ll go ahead and commit and push everything to the repository.


Output:
src/jarvis_finance/dashboard/data.py               |  37 +++-
 .../dashboard/pages/page_14_import_wizard.py       |   2 +-
 .../dashboard/pages/page_15_manual_review_queue.py |  71 +++++-
 .../dashboard/pages/page_16_data_quality_center.py |  12 +-
 src/jarvis_finance/imports/broker_mapping.py       | 242 +++++++++++++++++++++
 src/jarvis_finance/storage/migrations.py           |  15 +-
 tests/unit/test_broker_parser_dry_run_pipeline.py  | 141 +++++++++++-
 tests/unit/test_schema.py                          |   6 +-
 8 files changed, 495 insertions(+), 31 deletions(-)
[main 1c5c3a0] feat: harden broker review queue mapping workflow
 8 files changed, 495 insertions(+), 31 deletions(-)
........................................................................ [ 46%]
........................................................................ [ 92%]
...........                                                              [100%]
155 passed in 5.08s
GIT_SAFETY_OK
## main...origin/main [voraus 1]


set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
python - <<'PY'
import re, subprocess, sys
from pathlib import Path
repo=Path('/home/agent/.hermes/repos/FinanceManager')
text=Path.home().joinpath('jarvis_runtime/finance-system/secrets/Github_token_FinanceManager.csv').read_text()
m=re.search(r'(github_pat_[A-Za-z0-9_]+|ghp_[A-Za-z0-9_]+|gho_[A-Za-z0-9_]+)', text)
if not m:
    print('TOKEN_PARSE=failed'); sys.exit(12)
token=m.group(1); auth_url=f'https://{token}@github.com/Gamexgit/FinanceManager.git'
def run(args, check=True): return subprocess.run(args, cwd=repo, text=True, capture_output=True, check=check)
try:
    run(['git','fetch',auth_url,'main:refs/remotes/origin/main','--quiet'])
    local=run(['git','rev-parse','HEAD']).stdout.strip(); origin=run(['git','rev-parse','origin/main']).stdout.strip(); base=run(['git','merge-base','HEAD','origin/main']).stdout.strip()
    print('REMOTE_BEFORE='+origin[:7]); print('LOCAL_HEAD='+local[:7])
    if origin != base:
        print('REMOTE_HAS_NEW_COMMITS=yes'); sys.exit(3)
    push=run(['git','push',auth_url,'main:main'], check=False)
    if push.returncode:
        print('PUSH=failed'); print((push.stderr or push.stdout).replace(token,'[REDACTED]')[-1000:]); sys.exit(push.returncode)
    run(['git','fetch',auth_url,'main:refs/remotes/origin/main','--quiet'])
    print('PUSH=success'); print('REMOTE_AFTER='+run(['git','rev-parse','--short','origin/main']).stdout.strip())
finally:
    token=None; auth_url=None
PY
PYTHONPATH=src python -m jarvis_finance.cli.main git-safety-scan .
git status --short --branch


Output:
REMOTE_BEFORE=4e808ed
LOCAL_HEAD=1c5c3a0
PUSH=success
REMOTE_AFTER=1c5c3a0
GIT_SAFETY_OK
## main...origin/main


set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
PYTHONPATH=src python - <<'PY'
import json
from jarvis_finance.config.settings import load_settings
from jarvis_finance.storage.database import connect
from jarvis_finance.storage.migrations import apply_migrations
from jarvis_finance.imports.broker_mapping import get_ready_for_import_by_source, get_review_readiness_counts
conn=connect(load_settings().db_path); apply_migrations(conn)
status_counts={}
for row in conn.execute('SELECT source_platform, review_status, COUNT(*) AS n FROM broker_import_review_items GROUP BY source_platform, review_status ORDER BY source_platform, review_status').fetchall():
    status_counts.setdefault(row['source_platform'], {})[row['review_status']]=row['n']
productive={t: conn.execute(f'SELECT COUNT(*) AS n FROM {t}').fetchone()['n'] for t in ['positions_snapshot','transactions']}
print(json.dumps({'status_counts':status_counts,'ready_by_source':get_ready_for_import_by_source(conn),'readiness_counts':get_review_readiness_counts(conn),'productive_counts':productive}, sort_keys=True))
PY
git status --short --branch

Explanation:
**Collecting runtime counts**

I need to gather final runtime counts and see which modules have changed. It might be necessary to run a `git status` to check on everything. I think I should do this using the terminal, but I need to consider that there might not be any output values at this point. I'm trying to stay organized and ensure I have everything captured accurately before moving on!


Output:
{"productive_counts": {"positions_snapshot": 0, "transactions": 0}, "readiness_counts": [{"count": "4", "readiness_status": "blocked"}, {"count": "50", "readiness_status": "not_ready"}, {"count": "5", "readiness_status": "review_needed"}], "ready_by_source": [{"ready_for_import": "0", "source_platform": "PostFinance", "total": "34"}, {"ready_for_import": "0", "source_platform": "Raiffeisen", "total": "7"}, {"ready_for_import": "0", "source_platform": "True Wealth", "total": "18"}], "status_counts": {"PostFinance": {"open": 34}, "Raiffeisen": {"blocked": 4, "open": 3}, "True Wealth": {"open": 18}}}
## main...origin/main


cd /home/agent/.hermes/repos/FinanceManager && PYTHONPATH=src python - <<'PY'
import json
from jarvis_finance.config.settings import load_settings
from jarvis_finance.storage.database import connect
from jarvis_finance.storage.migrations import apply_migrations
conn=connect(load_settings().db_path); apply_migrations(conn)
counts={}
for t in ['positions_snapshot','transactions','cash_balances']:
    counts[t]=conn.execute(f'SELECT COUNT(*) AS n FROM {t}').fetchone()['n']
print(json.dumps(counts, sort_keys=True))
PY


Output: {"cash_balances": 0, "positions_snapshot": 0, "transactions": 0}


Erledigt, Sir. Phase B4 ist implementiert, getestet, committed und gepusht.

## Gesamtstatus

- Phase B4: **abgeschlossen**
- Commit: `1c5c3a0`
- Push Status: **erfolgreich**
- Remote HEAD: `1c5c3a0`
- Tests: `155 passed`
- Compile: **OK**
- Git-Safety: `GIT_SAFETY_OK`
- Git Status: **clean**, `main...origin/main`
- Echte Dateien ins Git: **nein**
- Echte Werte/Mengen im Chat: **nein**
- Produktive Positionen geschrieben: **nein**
- Cash-Snapshots geschrieben: **nein**
- Ledger-Transaktionen geschrieben: **nein**

## Neue/geänderte Module

Geändert:

- `src/jarvis_finance/imports/broker_mapping.py`
- `src/jarvis_finance/storage/migrations.py`
- `src/jarvis_finance/dashboard/data.py`
- `src/jarvis_finance/dashboard/pages/page_14_import_wizard.py`
- `src/jarvis_finance/dashboard/pages/page_15_manual_review_queue.py`
- `src/jarvis_finance/dashboard/pages/page_16_data_quality_center.py`
- `tests/unit/test_broker_parser_dry_run_pipeline.py`
- `tests/unit/test_schema.py`

Schema-Version:

- von `5` auf `6`
- Migration: `006_broker_review_queue_hardening`

## Implementiert: Review Queue Filter

Manual Review Queue erweitert um Filter für:

- Quelle:
  - PostFinance
  - True Wealth
  - Raiffeisen
- Dry Run Session
- Status:
  - open
  - blocked
  - mapped
  - ignored
  - resolved
- Quality Flag:
  - `missing_isin`
  - `missing_ticker`
  - `snapshot_only`
  - `cost_basis_uncertain`
  - `market_value_legacy`
  - `missing_fx`
  - `aggregate_only`
  - `missing_instrument_details`
  - `cash_snapshot_candidate`
  - `needs_manual_review`
- Assetklasse
- Währung
- Account Mapping Status
- Import Readiness Status

## Implementiert: Detailansicht pro Review Item

Die Runtime-UI kann nun pro Review Item anzeigen:

- Quelle
- Dry Run ID
- Source Row Reference
- Source Label
- Normalized Name
- erkannte Assetklasse
- erkannte Währung
- erkannte ISIN
- erkannter Ticker
- erkannte Exchange
- Account Mapping
- Quality Flags
- Review Status
- Import Readiness
- Reviewer Note
- Audit History

Hinweis: Details bleiben Runtime-UI/Runtime-DB. Keine echten Inhalte wurden in Tests, Fixtures, Docs oder Chat ausgegeben.

## Implementierte Review-Metadaten-Aktionen

Aktiviert als kontrollierte Backend-Funktionen mit Audit-Log:

### A. ISIN ergänzen

- grobe ISIN-Formatvalidierung
- entfernt `missing_isin`
- schreibt Audit-Log

### B. Ticker / Exchange ergänzen

- Ticker normalisiert
- Exchange normalisiert
- Ticker ohne Exchange bleibt review-pflichtig
- Flag `ticker_without_exchange`, falls nötig
- schreibt Audit-Log

### C. Exchange ergänzen

- über Ticker/Exchange-Aktion abgedeckt
- schreibt Audit-Log

### D. Instrument Mapping bestätigen

Regeln:

- ISIN erlaubt Mapping auf vorhandenes Instrument
- Ticker + Exchange nur mit expliziter Bestätigung
- Name-only darf **nicht** auf mapped gesetzt werden
- kein stilles Auto-Mapping
- schreibt Audit-Log

### E. Account Mapping bestätigen

Regeln:

- interne Account-ID wird bestätigt
- Cash darf nicht versehentlich auf Brokerage-only gemappt werden
- Brokerage/ETF/Equity darf nicht auf Cash-only gemappt werden
- schreibt Audit-Log

### F. Ignore with note

- Notiz Pflicht
- ohne Notiz abgelehnt
- Status: `ignored`
- Readiness: `ignored`
- schreibt Audit-Log

### G. Mark resolved

- nur möglich, wenn Pflichtprobleme gelöst sind
- sonst abgelehnt
- schreibt Audit-Log

## Implementiert: Import Readiness

Pro Review Item berechnet:

- `not_ready`
- `review_needed`
- `ready_for_import`
- `ignored`
- `blocked`

Regeln umgesetzt:

### Aktien/ETFs

`ready_for_import` nur wenn:

- Quelle vorhanden
- Account Mapping vorhanden
- Assetklasse `equity` oder `etf`
- ISIN vorhanden **oder** Ticker + Exchange explizit bestätigt
- Währung vorhanden
- Snapshot Date manuell bestätigt
- Menge vorhanden
- keine blockierenden Quality Flags
- Reviewer Confirmation vorhanden

### Cash

`ready_for_import` nur wenn:

- Account Mapping vorhanden
- Währung vorhanden
- Snapshot Date bestätigt
- Betrag/Market-Value-Presence vorhanden
- Reviewer Confirmation vorhanden

### Aggregate / Raiffeisen

- `aggregate_only` bleibt blockiert
- keine Instrumentposition daraus
- Cash-/Kontrollsnapshot nur reviewbar, wenn eindeutig

Sehr trocken, sehr sicher. Fast schon schweizerisch.

## Implementiert: Dry Run Session Management

Dry Run Sessions zeigen jetzt:

- Dry Run ID
- Quelle
- Dateityp
- Erstellungszeitpunkt
- Snapshot Date Status
- Anzahl Review Items
- Anzahl `ready_for_import`
- Anzahl `blocked`
- Anzahl `ignored`
- Anzahl `open`
- Warnings/Errors
- Session Status
- Current Marker

Vorbereitete Aktionen:

- Dry Run archivieren
- Dry Run verwerfen
- Dry Run als aktuell markieren

Regeln:

- keine Audit-Historie wird gelöscht
- kein produktiver Import
- Statusänderungen schreiben Audit-Log

## Data Quality Center erweitert

Neu sichtbar:

- Review Items je Quality Flag
- Readiness Counts:
  - `ready_for_import`
  - `not_ready`
  - `review_needed`
  - `blocked`
  - `ignored`
- Warnung, wenn eine Quelle `0 ready_for_import` hat
- Warnung bei fehlendem Snapshot Date
- Review Queue über Navigation/Filter nutzbar
- Buttons vorbereitet/deaktiviert:
  - Data Quality Recheck
  - Resolve Fixed Alerts
  - Review Items aktualisieren
  - Produktiven Import starten

Produktive Import-Buttons bleiben deaktiviert.

## Safe Mode / Write Enable

Weiter gestärkt:

- Runtime DB / echte Daten außerhalb Git bleibt sichtbar
- Write Mode bleibt default: `Read-only`
- Review-Metadaten-Aktionen sind fachlich getrennt von Portfolio-Writes
- produktive Portfolio-/Ledger-/Snapshot-Writes bleiben blockiert

Klare Trennung:

- Review-Metadaten schreiben: **erlaubt nach Bestätigung**
- Portfolio-/Ledger-/Snapshot schreiben: **weiterhin blockiert**

## Tests ergänzt

Neue/erweiterte Testabdeckung:

- Review Queue Filter nach Quelle
- Review Queue Filter nach Dry Run ID
- Review Queue Filter nach Quality Flag
- ISIN ergänzen erzeugt Audit
- Ticker/Exchange ergänzen erzeugt Audit
- Name allein bleibt nicht automatisch mapped
- Instrument Mapping mit ISIN kann `ready_for_import` werden
- Ticker ohne Exchange bleibt review-pflichtig
- Account Mapping Bestätigung erzeugt Audit
- Ignore with note funktioniert
- Ignore ohne Note wird abgelehnt
- Mark resolved nur bei gelösten Pflichtproblemen
- `ready_for_import` für Equity
- `ready_for_import` für ETF
- `ready_for_import` für Cash
- `aggregate_only` bleibt blockiert
- Dry Run archivieren / als aktuell markieren erzeugt Audit
- Data Quality Center zeigt Readiness Counts
- produktiver Import bleibt deaktiviert
- keine echten Dateien im Repo
- Git-Safety OK

Testergebnis:

- `155 passed`

## Runtime Review Item Counts nach Status

Aktueller Runtime-Stand nach B4-Readiness-Recheck:

### PostFinance

- open: `34`
- ready_for_import: `0`

### True Wealth

- open: `18`
- ready_for_import: `0`

### Raiffeisen

- open: `3`
- blocked: `4`
- ready_for_import: `0`

## Readiness Counts gesamt

- blocked: `4`
- not_ready: `50`
- review_needed: `5`
- ready_for_import: `0`

Das ist erwartbar: Es wurden noch keine echten manuellen ISIN-/Account-/Snapshot-Bestätigungen vorgenommen.

## Produktive Portfolio-Daten

Unverändert / keine produktiven Writes:

- `positions_snapshot`: `0`
- `transactions`: `0`
- `cash_balances`: `0`

## Commit / Push

- Commit: `1c5c3a0`
- Message: `feat: harden broker review queue mapping workflow`
- Push: **success**
- Git Status: **clean**

## Nächste Empfehlung

Phase B5 sollte sein:

**Guided Manual Review Pilot — kleine sichere Teilmenge freigeben, aber noch ohne produktiven Import.**

Vorschlag:

1. Eine Quelle auswählen, vermutlich PostFinance oder True Wealth.
2. 1–3 synthetisch harmlose echte Review Items im Dashboard manuell bearbeiten:
   - ISIN ergänzen
   - Ticker/Exchange ergänzen
   - Account Mapping bestätigen
   - Snapshot Date bestätigen
   - Instrument Mapping bestätigen
3. Prüfen, ob `ready_for_import` korrekt steigt.
4. Data Quality Center prüfen.
5. Audit History prüfen.
6. Weiterhin keinen produktiven Initial Snapshot committen.
7. Danach erst Phase B6: explizit freigegebener Mini-Import einer reviewed Safe Subset Position.

Kurz: Die Review Queue ist jetzt bedienbar und auditierbar. Noch schreibt sie brav nur Metadaten — kein Portfolio-Voodoo im Hintergrund.


[M G] Sehr gut. Phase B4 ist akzeptiert.

Der Stand ist sauber:

* Commit 1c5c3a0 gepusht
* Tests: 155 passed
* Git-Safety: OK
* Review Queue filterbar und auditierbar
* Data Quality Center erweitert
* Safe Mode / Read-only Mode aktiv
* keine produktiven Aktien-/ETF-/Cash-Imports
* keine Ledger-Transaktionen
* keine Cash-Snapshots
* keine positions_snapshot Writes
* keine echten Dateien im Git
* keine echten Werte/Mengen im Chat

Die Tatsache, dass aktuell ready_for_import = 0 ist, ist erwartbar, weil noch keine echten Review Items manuell gemappt wurden.

Bitte fahre nun mit Phase B5 fort.

# Phase B5 — Guided Manual Review Pilot

Ziel:
Wir wollen prüfen, ob der manuelle Review-/Mapping-Workflow mit echten Runtime Review Items funktioniert.

Wichtig:
Noch immer kein produktiver Import.
Noch keine produktiven Positionen.
Noch keine Ledger-Commits.
Noch keine Cash-Snapshots.
Noch keine positions_snapshot Writes.

## 1. Quelle für Pilot

Bitte starte mit True Wealth.

Begründung:

* weniger Review Items als PostFinance
* vermutlich stärker ETF-orientiert
* besser geeignet für einen kleinen Mapping-Pilot

Falls True Wealth keine sinnvoll mappbaren Items enthält, nimm alternativ PostFinance.

Raiffeisen bitte weiterhin defensiv behandeln:

* kein Instrumentimport aus aggregate_only Items
* höchstens Cash-/Kontrollsnapshot später

## 2. Pilot-Umfang

Bitte wähle 1–3 echte Review Items aus der Runtime Review Queue.

Auswahlkriterien:

* möglichst klare ETF-/Aktien-Bezeichnung
* keine aggregate_only Items
* keine Cash-Zeile für diesen ersten Pilot
* keine Position mit unklarem Account-Kontext
* bevorzugt True Wealth ETF-ähnliche Items

Bitte keine Mengen, Werte oder Kontostände im Chat ausgeben.

Wenn du Source Labels für Mapping brauchst:

* entweder nur minimal nennen, ohne Werte/Mengen
* oder besser: lokale Runtime Review UI/Mapping-Struktur verwenden und im Chat nur aggregiert berichten

## 3. Mapping-Aktionen durchführen

Für die ausgewählten 1–3 Review Items bitte kontrolliert durchführen:

A. ISIN ergänzen, falls sicher bekannt

* ISIN validieren
* Audit-Log schreiben
* missing_isin entfernen

B. Ticker ergänzen, falls sinnvoll

* Ticker normalisieren
* Exchange ergänzen
* Audit-Log schreiben

C. Exchange ergänzen

* z.B. SIX, XETRA, NASDAQ, NYSE, LSE, SWX je nach Instrument
* Audit-Log schreiben

D. Account Mapping bestätigen

* True Wealth Review Item auf korrektes internes True-Wealth-Konto mappen
* Cash/Brokerage/Robo-Portfolio nicht vermischen
* Audit-Log schreiben

E. Snapshot Date bestätigen

* Falls Stichtag aus Datei fehlt oder unsicher ist, bitte vorerst als manuell bestätigt markieren, aber mit Quality Note
* Kein produktiver Import
* Audit-Log schreiben

F. Instrument Mapping bestätigen

* Nur wenn ISIN oder Ticker + Exchange vorhanden ist
* Name allein darf nicht mapped werden
* Audit-Log schreiben

G. Mark resolved / ready prüfen

* Nur wenn alle Pflichtprobleme gelöst sind
* Import Readiness muss korrekt auf ready_for_import wechseln
* Audit-Log schreiben

## 4. Import Readiness prüfen

Bitte nach dem Pilot prüfen:

* Anzahl bearbeiteter Review Items
* Anzahl Items, die von not_ready oder review_needed auf ready_for_import gewechselt sind
* Anzahl weiterhin blockiert
* Anzahl weiterhin open
* Audit-Logs vorhanden
* Data Quality Center aktualisiert
* Manual Review Queue zeigt Status korrekt
* keine produktiven Portfolio-Daten geschrieben

Bitte keine Werte/Mengen/Kontostände ausgeben.

## 5. Kein produktiver Import

Bitte jetzt weiterhin nicht:

* keine produktiven Positionen schreiben
* keine Ledger-Transaktionen schreiben
* keine Cash-Snapshots schreiben
* keine positions_snapshot schreiben
* keine echten Reports mit Aktien-/ETF-Zahlen erzeugen
* keine echten Dateien ins Git
* keine echten Werte/Mengen im Chat

Das Ziel ist nur:

* Review Workflow testen
* Mapping-Aktionen testen
* Audit testen
* ready_for_import erzeugen

## 6. Falls echte ISIN/Ticker nicht sicher bestimmbar sind

Falls du die ISIN/Ticker nicht sicher bestimmen kannst:

* nicht raten
* Item nicht ready_for_import
setzen
* als needs_manual_review belassen
* im Bericht nur sagen:

  * Anzahl Items wegen unsicherem Instrument-Mapping nicht bereit
  * keine Werte/Mengen
  * keine riskanten automatischen Mappings

Optional:

* Vorschlag machen, welche zusätzlichen Informationen ich liefern sollte
* z.B. besserer Broker-Export mit ISIN/Valor/Ticker

## 7. Tests / Safety

Nach Abschluss:

* Compile
* pytest
* Git-Safety
* Git Status

Falls Code geändert wurde:

* Commit
* Push

Wenn nur Runtime-Metadaten geändert wurden:

* kein Git-Commit nötig
* aber Git-Safety und Git Status prüfen

## 8. Bericht

Bitte berichten:

* Quelle des Pilots
* Anzahl ausgewählte Review Items
* Anzahl erfolgreich gemappt
* Anzahl ready_for_import vorher/nachher
* Anzahl weiterhin not_ready/review_needed/blocked
* Audit-Logs erstellt: ja/nein
* Data Quality Center aktualisiert: ja/nein
* Manual Review Queue aktualisiert: ja/nein
* Produktive Portfolio-Daten unverändert: ja/nein
* Git-Safety Ergebnis
* Git Status
* ob Phase B6 Mini-Import einer sicheren Position vertretbar wäre

Bitte keine echten Mengen, Werte, Kontostände oder sensitiven Dateiinhalte ausgeben.


Explanation:
**Inspecting data needs**

I need to act and inspect the data. I have already loaded the relevant skills. Maybe I should use the terminal now. I want to avoid including values in the output. It’s essential to identify the True Wealth labels, which may need an ISIN. I could use the web for that, but the labels might include names without values. I'll need to query the sanitized labels without exposing any sensitive information. Let’s check the schema and data!

todo

Runtime Review Items für True Wealth prüfen und geeignete Pilot-Items ohne Werte/Mengen auswählen

Sichere ISIN/Ticker/Exchange ermitteln und Review-Metadaten-Aktionen durchführen

Readiness, Audit, Data Quality und produktive Unverändertheit verifizieren

Compile, pytest, Git-Safety, Git Status prüfen; ggf. Commit/Push nur bei Codeänderung


terminal

set -euo pipefail
cd /home/agent/.hermes/repos/FinanceManager
PYTHONPATH=src python - <<'PY'
import json
from jarvis_finance.config.settings import load_settings
from jarvis_finance.storage.database import connect
from jarvis_finance.storage.migrations import apply_migrations
conn=connect(load_settings().db_path); apply_migrations(conn)
rows=conn.execute('''
SELECT review_item_id, dry_run_id, source_row_ref, source_label, normalized_name, detected_asset_class, detected_currency, quality_flags_json, review_status, import_readiness_status, account_mapping_status
FROM broker_import_review_items
WHERE source_platform='True Wealth' AND review_status IN ('open','mapped','resolved')
ORDER BY source_row_ref
''').fetchall()
# Internal diagnostic only: redact any obvious numeric chunks from labels to avoid value leakage in tool output too.
def red(s):
    import re
    if s is None: return None
    return re.sub(r'\b\d+(?:[.,]\d+)?\b','[num]',str(s))[:220]
print(json.dumps([{k:(red(r[k]) if k in {'source_label','normalized_name'} else r[k]) for k in r.keys()} for r in rows], ensure_ascii=False, indent=2))
PY