Files
encyclopedia-knowledge-graph/docs/archive/PLAN-ONE-SHOT-TICKER-STATS-CARDS-API-PNG-AND-JSON.md
T

19 KiB
Raw Blame History

Plan: One-Shot Ticker Stats Card Generator & API (.png + .json) — Pokémon / Sports Card / TCG / TierZoo Hybrid in the haiperdohp-jemaytreeah Visual Design System (v2.0.24)

  • Document ID: PLAN-ONE-SHOT-TICKER-STATS-CARDS-API-PNG-AND-JSON (v2.0.24)
  • Roadmap Status: ACTIVE / READY
  • Strict Zero-Synthetic-Data & Null-Preserving Mandate: Every market price, basis-point move, 20-day volume ratio, sabermetric moment (SNAP%, WOPR, WAR_30d), and Dose 0..3+ confluence score rendered on the .png card and emitted in the .json file comes 100% from real exchange observations (site/quant/real-market-history.json) and real dated news dossiers (25..71-dossier-news-YYYY-MM-DD.md). Whenever market data is unavailable (such as private entity ANTHR-PVT, closed weekend/holiday equity sessions, or unreported equity market_cap_str), the .json field is null (None in Python) and the .png card explicitly prints "No data available" / "N/A"—never 0.0 and never synthesized.
  • Target Modules, Existing Chatbot REST Dispatcher & MCP Integration (0 New REST Endpoints):
    • /workspace/hyperstitionstudio-core/src/hyperstitionstud_io/quant/cards.py (hs-ticker-card CLI & deterministic Pillow .png + .json compiler)
    • /workspace/hyperstitionstudio-core/src/hyperstitionstud_io/mcp/tools.py (Wired into MCP & the existing Chatbot OpenAPI /api/v1/tools/{tool_name}, /api/v1/zoology/pokedex/{symbol}, and /api/v1/quant/timeseries dispatchers—creating zero new REST endpoint routes in src/hyperstitionstud_io/mcp/rest.py)
    • /workspace/hyperstitionstudio-core/schemas/v1/ticker-stats-card.schema.json (Offline URN JSON Schema contract)
    • /workspace/hyperstitionstudio-core/tests/test_core_suite.py

1. Visual Design System: Matching the haiperdohp-jemaytreeah Calculator (calc/styles.css & calc/ciphers.js)

To make every generated .png card look like a native artifact of the haiperdohp-jemaytreeah Cypher Calculator (/calc/), the Pillow renderer (hyperstitionstud_io.quant.cards) uses the exact HSL/RGB color tokens, zebra-table rows, breakdown boxes, and cipher accent hues defined in /workspace/haiperdohp-jemaytreeah/calc/styles.css, config.default.js, and calc/ciphers.js:

haiperdohp-jemaytreeah CSS / JS Token Exact Color Value (HSL -> Hex / RGB) Where It Appears on the Ticker Stats Card .png (900 × 1260 px, 5:7 TCG Portrait)
--body-bg-accent (hue=222, sat=22%, lit=16%) #1f2532 (rgb(31, 37, 50)) Main card chassis background inside the outer bevel frame.
--breakdown-bg-accent (hue=222, sat=21%, lit=13%) #1a1f29 (rgb(26, 31, 41)) Recessed word-breakdown & 30-day sparkline viewport (#BreakdownSpot / #ChartSpot style).
--hist-header-gradient (hue=222, sat=13%, lit=10%) #16181d (rgb(22, 24, 29)) Top TCG header banner & section title bars.
--menu-bg-accent / --menu-bg-accent2 #394356 / #313949 Pill badges, guild type tags (S1..S6), and stat-box headers.
--table-row-odd & --table-row-even #1e2229 & #24272e Alternating zebra stripes in the Sports-Card Season Box Score table and Cipher Table.
--border-accent & --border-dark-accent #696969 (1px) & #3b3b3b (2px) Crisp 1px cell borders and 2px inner frame dividers matching #enabledCiphTable.
CALC_CONFIG.logoColor & Matrix Hover #2eb872 (hsl(148, 60%, 45%)) & #00ffcc Ticker symbol glow, active lock highlights, and "Cypher Calculator // hyperstitionstud.io" header stamp.
Cipher 1: Ordinal (hsl(120, 65%, 62%)) #5cd65c (rgb(92, 214, 92)) Ordinal cipher column & VEL (Velocity) stat bar accent.
Cipher 2: Reduction (hsl(216, 95%, 73%)) #79aafb (rgb(121, 170, 251)) Reduction cipher column & RES (Resilience) stat bar accent.
Cipher 3: Alphanumeric Qabbala (hsl(60, 33%, 62%)) #bebe7e (rgb(190, 190, 126)) Primary Base-36 AQ (Gen 0 & Gen 1) score badges & ARM (Isometric Chokepoint) bar.
Cipher 4: Primes (hsl(44, 56%, 62%)) #d4b268 (rgb(212, 178, 104)) Primes rank badge ([33rd PRIME], [44th PRIME]) & PRM stat bar.
Cipher 5: Synx (hsl(180, 44%, 66%)) #82cece (rgb(130, 206, 206)) Synx / COL (G1 Variance Collapse) stat bar & 30-day sparkline curve.
Cipher 6: Based Atlanteanism (hsl(280, 55%, 68%)) #bf7ee0 (rgb(191, 126, 224)) CAP (Trophic Capture) stat bar & Dose 2/3+ cross-species confluence badge.

2. Hybrid Card Anatomy: Fusing Pokémon TCG, Sports Cards, Trading Card Games & TierZoo (900 × 1260 px)

Each generated card integrates five distinct zones modeled on the best conventions of trading card games, back-of-card sports sabermetrics, and TierZoo scorecards:

+===================================================================================+
| [STAGE 3 APEX]  NVDA // NVIDIA -> envideea      [TIER S+ | 85.4 ETI] [S1 AI][S3] | <- Zone 1: Pokémon/TCG Header
| DEX #137 [33rd PRIME] • Symbol AQ: 77 • NASDAQ:NVDA        (#16181d + #2eb872 glow)|
+-----------------------------------------------------------------------------------+
| ZONE 2: HAIPERDOHP-JEMAYTREEAH MULTI-CIPHER BREAKDOWN & 30-DAY REAL TAPE VIEWPORT |
| +-------------------------------------------+-----------------------------------+ |
| | #BreakdownSpot: "e-n-v-i-d-e-e-a"         | #ChartSpot: 30-Day Real Close USD | |
| | 14+23+31+18+13+14+14+10 = 137 [33rd PRIME]|   $212.06 Peak (Nov 04)           | |
| |-------------------------------------------|   /\_/\    /\                     | |
| | CIPHER TABLE (Gen 0 Written vs Gen 1 Ing):|  /     \__/  \___ $150.49 (Nov 27)| |
| | • Base-36 AQ:  113 (Gen 0) -> 137 (Gen 1) |  • 19/30 Real Sessions Available  | |
| | • Ordinal:      63 (Gen 0) ->  65 (Gen 1) |  • 11 Closed Days = null (N/A)    | |
| | • Reduction:    27 (Gen 0) ->  29 (Gen 1) |  • Peak Volume: 4.52x (Nov 12)    | |
| | • Phonemic Drift (Δ): +24 (Prime -> Prime)|  • Confluence Dose Peak: D = 3/4  | |
| +-------------------------------------------+-----------------------------------+ |
+-----------------------------------------------------------------------------------+
| ZONE 3: TIERZOO 6-STAT ECOLOGICAL SCORECARD & RADAR BARS (0–100 SCALE)            |
|  ARM (Chokepoint Armor)    [███████████████░░░░░]  76.0   (#bebe7e AQ Brass)      |
|  VEL (Signal Velocity)     [████████████████░░░░]  80.6   (#5cd65c Ordinal Green) |
|  COL (G1 Var Collapse)     [██████████████████░░]  91.0   (#82cece Synx Cyan)     |
|  CAP (S×S6 Capture Reach)  [█████████████████░░░]  84.0   (#bf7ee0 Atlantean)     |
|  PRM (Prime Mutation IQ)   [███████████████████░]  95.0   (#d4b268 Primes Gold)   |
|  RES (Repricing Ward)      [████████████░░░░░░░░]  61.6   (#79aafb Reduction Blue)|
+-----------------------------------------------------------------------------------+
| ZONE 4: SPORTS-CARD BACK-OF-CARD REAL SEASON BOX SCORE (Zebra Table #1e2229/#24272e)|
| +---------+----------+-----------+--------+-------+------+---------+------+-----+ |
| | SESS    | CLOSE    | MOVE(BPS) | VOL20D | SNAP% | WOPR | WAR_30d | LAG* | DOSE| |
| | 19 / 30 | $150.49  | +80 bps   | 0.53x  | 26.3% | 24.1 | -1.46   | -1d  | 2/4 | |
| +---------+----------+-----------+--------+-------+------+---------+------+-----+ |
| | P20 FLOOR: 42.0  | P90 CEIL: 65.3  | NEXT-DAY CONT%: 60.6% | CAP: No data avail| |
| +-------------------------------------------------------------------------------+ |
+-----------------------------------------------------------------------------------+
| ZONE 5: TCG PASSIVE ABILITY, SIGNATURE EQUATION MOVE & GROUNDED CITATION FOOTER   |
| • [NATURE & ARCHETYPE]: Modest (+SPA / -ATK) • Balanced Multi-Factor Core         |
| • [PASSIVE ABILITY — M1/M2 REGIME SPLIT]: Supply-Halt & Wire Co-Presence Surge    |
|   (On 2026-11-12 & 2026-11-13, Dossier 52/53 confluence drove 4.52x & 1.86x vol)  |
| • [SIGNATURE 333 EQUATION MOVE]:                                                  |
|   `envideea (137) + fohldz (125) + gpu (71) = 333` ("Nvidia folds GPU" — Doss. 67)|
+-----------------------------------------------------------------------------------+
| urn:io:hyperstitionstud:card:NVDA:v2.0.24 • CIDv1: baguqeera... • ♥ by Lemurs.    |
+===================================================================================+

3. Unified JSON Schema (ticker-stats-card.schema.json) & Dual .png + .json Output Contract

Every one-shot card request returns (and/or writes to disk) a synchronized pair of artifacts—<symbol>-stats-card.png and <symbol>-stats-card.json—governed by /workspace/hyperstitionstudio-core/schemas/v1/ticker-stats-card.schema.json:

{
  "$schema": "./schemas/v1/ticker-stats-card.schema.json",
  "$id": "urn:io:hyperstitionstud:schema:v1:ticker-stats-card",
  "version": "2.0.24",
  "synthetic_data_eliminated": true,
  "card_identity": {
    "symbol": "NVDA",
    "symbol_clean": "NVDA",
    "symbol_eng_aq": 77,
    "symbol_ing_aq": 77,
    "entity_eng": "Nvidia",
    "entity_ing": "envideea",
    "dex_number": "DEX #137",
    "guilds": ["S1", "S3"],
    "tier_band": "Tier S (Keystone Guild)",
    "evolution_stage": "Stage 3 (Keystone Pseudo-Legendary)",
    "composite_eti_score": 81.9,
    "selected_lens": "tierzoo_ecology",
    "tradingview_symbol": "NASDAQ:NVDA",
    "tradingview_url": "https://www.tradingview.com/chart/?symbol=NASDAQ%3ANVDA"
  },
  "cipher_breakdown": {
    "word_letters_ing": ["e", "n", "v", "i", "d", "e", "e", "a"],
    "word_values_aq": [14, 23, 31, 18, 13, 14, 14, 10],
    "eng_aq": 113,
    "ing_aq": 137,
    "eng_prime_rank": 30,
    "ing_prime_rank": 33,
    "eng_ordinal": 63,
    "ing_ordinal": 65,
    "eng_reduction": 27,
    "ing_reduction": 29,
    "phonemic_drift_delta": 24,
    "is_isometric": false,
    "is_twin_prime": false
  },
  "tierzoo_base_stats_6": {
    "struct_isometric_armor": 76.0,
    "struct_drift_velocity": 80.6,
    "struct_variance_collapse": 91.0,
    "struct_trophic_capture": 84.0,
    "struct_prime_density": 95.0,
    "struct_repricing_resilience": 61.6
  },
  "sports_card_box_score": {
    "observation_date_utc": "2026-11-27",
    "data_available": true,
    "status": "ok",
    "available_trading_days": 19,
    "missing_trading_days": 11,
    "close_usd": 150.49,
    "change_pct": 0.80,
    "change_bps": 80,
    "volume_ratio_20d": 0.53,
    "market_cap_str": null,
    "close_spoken_eng": "one hundred fifty",
    "close_spoken_eng_aq": 196,
    "close_spoken_ing": "wuhn huhndrad fiftee",
    "close_spoken_ing_aq": 215,
    "bps_spoken_eng": "eighty",
    "bps_spoken_eng_aq": 128,
    "bps_spoken_ing": "aytee",
    "bps_spoken_ing_aq": 98,
    "confluence_dose": 2,
    "shared_dossier_coordinates": [128],
    "duty_cycle_snap_pct": 26.3,
    "wopr_resonance": 24.1,
    "war_30d_excess": -1.46,
    "quantile_profile": {
      "p20_floor": 42.0,
      "p90_ceiling": 65.3,
      "boom_pct": 5.3,
      "bust_pct": 73.7,
      "cv": 1.85
    },
    "optimal_lag_days": -1,
    "sparkline_30d": "·█▆▆▅▄··▄▄▆▄▃··▃▃▄▃▃··▃▃▃▃·▃··"
  },
  "tcg_abilities_and_moves": {
    "nature": "Modest (+SPA / -ATK • Prime Harmonic Resonator)",
    "archetype": "Opportunistic Burst Predator",
    "passive_ability": "M3 Leviathan / Cross-Species Dossier Lock",
    "ev_yield": "+2 SPE, +1 ATK",
    "signature_equation": "envideea (137) + fohldz (125) + gpu (71) = 333",
    "doc_references": {
      "encyclopedia_deep_link": "/encyclopedia/03-machinic-phylum-guilds-s1-to-s5/class-s3-silicon-war-machine-and-euv-swarm-a-to-z.pdf#page=5&search=envideea",
      "knowledge_graph_deep_link": "/graph/index.html?select=aq:137",
      "exemplar_dossier_deep_link": "/zoology/dossiers/65-dossier-technocapital-singularity-autoregressive-ai.md#:~:text=292"
    }
  },
  "artifacts": {
    "png_file_path": "/tmp/hyperstition-cards/NVDA-stats-card.png",
    "json_file_path": "/tmp/hyperstition-cards/NVDA-stats-card.json",
    "png_mime_type": "image/png",
    "png_dimensions": [900, 1260],
    "png_sha256": "...",
    "png_base64": "iVBORw0KGgoAAAANSUhEUg..."
  },
  "ipld_dag_json_cidv1": {
    "/": "baguqeera..."
  }
}

(When requested for a private/untraded entity like ANTHR-PVT or a closed weekend date, sports_card_box_score.data_available is false, all numeric market fields are null, and the rendered .png card displays "No data available" in the box-score cells without fabricating a single number).


4. Chatbot REST API & MCP Integration Specification (0 New REST Endpoints Created)

Because /api/v1/* (src/hyperstitionstud_io/mcp/rest.py) is designed exclusively as the Chatbot & OpenAPI 3.1.0 REST Adapter mirroring MCP_TOOLS_SCHEMA, no new custom REST endpoint routes are created in rest.py. Instead, the one-shot .png + .json card generator integrates directly into the existing Chatbot REST and MCP tool infrastructure:

4.1 Exclusive Use of Existing Chatbot REST Routes (src/hyperstitionstud_io/mcp/rest.py Unchanged in Route Surface)

Existing Chatbot REST Route / Protocol How Chatbots & AI Agents Request the One-Shot .png + .json Ticker Stats Card
1. Existing Parameterized Chatbot Route:
GET /api/v1/zoology/pokedex/{symbol}?include_card=true (or /api/v1/quant/timeseries?symbol={symbol}&include_card=true)
Already routed in rest.py (lines 288–295 & line 40) to hs_inspect_quant_timeseries. Passing include_card=true (or invoking hs_generate_ticker_stats_card via the generic tool dispatcher below) compiles and attaches both the .json stats card object and the .png card artifact (png_file_path, json_file_path, png_sha256, and png_base64 / data:image/png;base64,...) inside the standard Chatbot REST JSON envelope—requiring zero new endpoints.
2. Existing Generic Chatbot Tool Dispatcher:
GET | POST /api/v1/tools/hs_generate_ticker_stats_card
Automatically handled by the existing generic /api/v1/tools/{tool_name} dispatcher in rest.py (lines 365–392) and automatically added to /api/v1/openapi.json (build_openapi_v1_spec()) the moment hs_generate_ticker_stats_card is registered in MCP_TOOLS_SCHEMA. No route changes in rest.py are needed.
3. MCP JSON-RPC 2.0 (/mcp & stdio):
tools/call -> hs_generate_ticker_stats_card
Returns the structured .json card payload, writes the .png and .json files to the configured output directory, and includes the base64-encoded .png image content block for multimodal MCP clients.

4.2 MCP & Chatbot Tool Specification (src/hyperstitionstud_io/mcp/tools.py)

  • Tool Name: hs_generate_ticker_stats_card (plus optional include_card: true parameter on existing hs_inspect_quant_timeseries)
  • Description: "Generate a one-shot hybrid Pokémon/Sports/TCG/TierZoo ticker stats card (.png + .json) styled after the haiperdohp-jemaytreeah Cypher Calculator using 100% real exchange and news-wire observations (null / 'No data available' when absent)."
  • Input Schema (inputSchema):
    • symbol (string, required): Ticker symbol or DEX coordinate (e.g. "NVDA", "PLTR", "SOL-USD", "ASML", "ANTHR-PVT", "137").
    • lens (string, default "tierzoo_ecology"): "tierzoo_ecology" | "fund_manager" | "corporate_board" | "fantasy_sabermetrics" | "pokedex_scanner" | "neutral_math".
    • date_utc (string, optional): Target UTC date YYYY-MM-DD (defaults to latest available real trading date for that symbol).
    • include_base64_png (boolean, default True): Embeds the rendered .png bytes as base64 (png_base64) alongside the emitted .png and .json file paths so stateless HTTP chatbots receive both the .png image and .json data in a single JSON response.
  • Read-Only Isolation Guarantee: Executes inside ReadOnlyIsolationGuard, writing generated .png and .json files only to /tmp/hyperstition-cards/ (or a user-specified external output directory in CLI mode) and never mutating protected repository registries.

5. Three-Phase Implementation Roadmap (Phases 1–3, Zero New Endpoints)

Phase 1: Build src/hyperstitionstud_io/quant/cards.py, Schema & hs-ticker-card CLI

  1. Create /workspace/hyperstitionstudio-core/schemas/v1/ticker-stats-card.schema.json with offline $id: "urn:io:hyperstitionstud:schema:v1:ticker-stats-card".
  2. Create /workspace/hyperstitionstudio-core/src/hyperstitionstud_io/quant/cards.py implementing:
    • build_ticker_stats_card_json(symbol, lens="tierzoo_ecology", date_utc=None): Computes the 5-zone card JSON strictly from real observations (None / null when unavailable), including the haiperdohp-jemaytreeah multi-cipher character breakdown (Alphanumeric Qabbala, Ordinal, Reduction, Primes).
    • render_ticker_stats_card_png_bytes(card_json): Renders the 900 × 1260 px RGBA PNG in memory using Pillow and the DejaVu Sans / DejaVu Sans Mono TrueType fonts in the haiperdohp-jemaytreeah silhouette & palette.
    • export_ticker_stats_card_pair(symbol, out_dir, lens="tierzoo_ecology", date_utc=None): Writes both <symbol>-stats-card.png and <symbol>-stats-card.json to out_dir and returns the combined payload with png_base64, png_sha256, and ipld_dag_json_cidv1.
  3. Register hs-ticker-card = "hyperstitionstud_io.quant.cards:main" in pyproject.toml.

Phase 2: Wire into src/hyperstitionstud_io/mcp/tools.py (Automatic Chatbot REST Coverage, 0 New Endpoints)

  1. Register hs_generate_ticker_stats_card in MCP_TOOLS_SCHEMA and call_mcp_tool() in src/hyperstitionstud_io/mcp/tools.py (which the existing /api/v1/tools/{tool_name} dispatcher and /api/v1/openapi.json builder in src/hyperstitionstud_io/mcp/rest.py expose automatically without adding any new route).
  2. Add optional include_card: boolean support to hs_inspect_quant_timeseries so the existing /api/v1/zoology/pokedex/{symbol} and /api/v1/quant/timeseries chatbot endpoints can also return the one-shot .png + .json card bundle on demand.

Phase 3: Verification in tests/test_core_suite.py

  1. Add unit assertions in tests/test_core_suite.py verifying:
    • build_ticker_stats_card_json("NVDA") and build_ticker_stats_card_json("PLTR") return real exchange data with synthetic_data_eliminated == True,
    • build_ticker_stats_card_json("ANTHR-PVT") returns data_available == False and close_usd is None (null in JSON) and renders "No data available" on the .png card,
    • Calling the existing Chatbot REST tool dispatcher GET /api/v1/tools/hs_generate_ticker_stats_card?symbol=NVDA (and GET /api/v1/zoology/pokedex/NVDA?include_card=true) returns HTTP 200 OK with both the .json card specification and valid (900, 1260) .png bytes (\x89PNG\r\n\x1a\n),
    • Calling dispatch_jsonrpc (tools/call: hs_generate_ticker_stats_card) returns HTTP 200 OK with matching CIDv1 digests, and
    • Confirming that zero new custom endpoint patterns were added to src/hyperstitionstud_io/mcp/rest.py.