portfolio-ledger
Read positions, exposure, and P&L from the append-only ledger with restart reconciliation and JSONL export, owned by JOURNAL with RISK reading.
SKILL.mdskills/portfolio-ledger/SKILL.md
GitHubPortfolio Ledger
L1 - Summary
The ledger is the desk's memory: every event appended once, hash-chained, never edited. JOURNAL owns reads for reports and reconciliation; RISK reads exposure and P&L for limit decisions. After any restart, reconcile from the chain before trusting a single number.
append-only events -> hash chain verifies -> exposure and P&L read -> reports and limits
restart -> reconcile from chain -> then read
L2 - Method
- S1 - Read through the tools: use
portfolio.ledger_readfor event history,portfolio.exposurefor current exposure, andportfolio.pnlfor realised and unrealised P&L. Never read the sqlite file directly when a tool exists. - S2 - Reconcile after restart: verify the hash chain (
seqwithout gaps, everyprev_hashmatching) before serving numbers. A chain that does not verify stops reads until repaired from the last good snapshot. - S3 - Speak event types: the ledger carries the snake_case event kinds (order, fill, halt, kill, approval, journal_note, escalation). Filter by kind and ticket; never invent a kind.
- S4 - Export as JSONL: snapshots and exports go to versioned JSONL views for reports and audits. Exports are derived views; the chain stays the single truth.
- S5 - Separate writing from reading: seats write ledger events only through
journal.appendanddesk.event_emitwith kindsjournal_noteorescalation. Every other event type is appended by library code only.
Failure modes
| Symptom | Cause | Action |
|---|---|---|
| Chain gap or hash mismatch | Crash mid-append or file tampering | Stop reads; reconcile from the last good snapshot; report to RISK |
| Direct sqlite reads in code | Bypassed tooling | Route through the portfolio tools; direct reads skip freshness and audit |
| Invented event kind | Typo or new-kind wish | Use the enumerated kinds; new kinds arrive via reviewed schema change |
| Seat writing non-journal events | Authority confusion | Refuse; only the adapter, engine, supervisor, or CLI append those kinds |
References
- Tools:
portfolio.ledger_read,portfolio.exposure,portfolio.pnl(ledger reads) - Event vocabulary: ledger event kinds (
journal_note,escalation, order and fill rows) - Gate G-2: ledger rows back every receipted claim
- Companion skills:
desk-folders-and-journal(layout plus append-only rule),daily-report(report rendering)