Skip to content

feat(tui): venues visibility and the help & glossary system (#394 C7) - #406

Merged
eaitbrahim merged 1 commit into
mainfrom
feat/394-brokers-help
Aug 19, 2026
Merged

feat(tui): venues visibility and the help & glossary system (#394 C7)#406
eaitbrahim merged 1 commit into
mainfrom
feat/394-brokers-help

Conversation

@eaitbrahim

Copy link
Copy Markdown
Contributor

Closes the console PRD's C7 slice: O7 (venues/brokers visibility, service-first) and O8 (the newbie help & glossary system). Test-first: the new suites were written red (tests/commands/test_brokers.py, tests/commands/test_help_console.py — both failed at import before a line of implementation), then made green.

The brokers service (O7) — one service, two front-ends

keel/commands/brokers.py::list_installed_brokers() walks the entry-point registry (discover_brokers()), constructs each adapter credential-less, and renders one frozen BrokerInfo row per installed adapter:

name, venue, deployment ("wired-for-deployment" | "optional-dev-venue"),
session_bound, quote_currencies, asset_classes, supported_orders,
preview ("native" | "synthesized" | "none"), supports_fee_summary,
declared_endpoints, supported_data_feeds, package_version
  • Every field derives from the adapter's own declarations (capabilities(), the new DECLARED_ENDPOINTS/DECLARED_DATA_FEEDS on AlpacaAdapter — derived from TRADING_HOSTS/SUPPORTED_DATA_FEEDS, never a second list). Pinned: the payload fields equal the adapters' declarations, per field.
  • No secrets, no key-presence inference (Venue visibility must be capability-based, not key-presence-based — a read-only key looks identical to a working one #233-aligned): the field set is closed and pinned by test; the payload is JSON-scanned for secret vocabulary; the screen and CLI both carry the shared NO_KEY_INFERENCE_LINE.
  • Wired vs optional is ONE explicit constant (WIRED_FOR_DEPLOYMENT = {coinbase, alpaca}) with its reasoning in place — no registry signal carries it.
  • Front-ends: keel brokers list (+ --json following status --json's convention, no disclaimer after JSON; the README's trademark line in the docstring) and the TUI Venues browser under Profile (console.build_venues_lines): same payload via the service's shared capability_facts wording, the SELECTED adapter highlighted [selected], the active deployment's binding (config+db pair; endpoint/data feed where the venue declares them) named. The one-payload/two-front-ends equality is pinned by test; the browser's facts are read once per entry, never per poll.

The glossary (O8) — one source, anchored

docs/glossary.md is the ONE new hand-written file and the only place console terms are defined. Seeded with the console's needed terms (rail; attestation + instrument attestation; exemption; screening; promotion gate; paper/live mode; kill switch; autonomy; qabd; riba; gharar; maysir/maisir alias; purification; session-bound venue; market clock; trust window; DCA benchmark; granularity; trials ledger). Design as built:

  • Fiqh terms' definitions are verbatim passages of docs/fiqh-basis.md, each carrying the document's exact section heading as its citation; gharar says "not stated in docs/fiqh-basis.md" exactly as C3's shariah screen does. Pinned against the document (spot-pins: qabd, riba word-for-word) and pinned equal to compliance_console.VOCABULARY, so the two surfaces cannot drift.
  • The TUI renders it bounded-read and mtime-cached (the research readers' discipline — MAX_GLOSSARY_BYTES, cached_glossary per (path, mtime_ns)); an absent file (an installed deployment has no docs/ checkout) is a calm empty state naming the path.
  • Rule parameters are never duplicated: the Help menu's parameter view renders rules.describe_params (the classes' own docstrings/defaults/types/choices, by introspection) — pinned to contain describe_params' actual doc strings for turtle_breakout's full param set; the glossary's granularity entry points there too.

The contextual help registry (O8)

Each console module owns its screens' rows (CONTEXT_HELP: plain (subject, description) pairs keyed by mode — text lives with the module that owns the screen); keel/commands/help_console.py is the registry (CONSOLE_MODES + lazy mode→owner resolution) and renderer. ? opens the current mode's overlay from every console mode and q/Esc/? returns to the screen it was opened from — pinned three ways: the registry is total over run_live's dispatched modes, a structural scan asserts every mode == branch in run_live handles ord("?"), and behavioral run_live tests drive the overlay open/close. The typed actions' help states the prompt cannot be pre-filled (pinned: ≥4 occurrences, on the trading/compliance/strategy screens). The Help menu entry becomes a real sub-menu: glossary · screens & actions (the consolidated catalog) · rule parameters · keys & safety (the pre-C7 help screen, kept whole).

Gates

  • uv run pytest -q — 3598 passed, 3 skipped
  • uv run ruff check keel tests packages — clean
  • uv run mypy — clean (277 files)

Fixes #394

The console PRD's C7 slice -- O7 (venues/brokers visibility) and O8 (the
help & glossary system), one service per truth and two front-ends over it.

The brokers service (O7): `keel.commands.brokers.list_installed_brokers()`
walks the entry-point registry (`discover_brokers()`), constructs each
adapter credential-less, and renders one BrokerInfo per installed adapter
-- name, venue, wired-for-deployment vs optional-dev-venue (ONE explicit
constant, `WIRED_FOR_DEPLOYMENT`, with its reasoning in place), session-
bound or 24/7, quote currencies, asset classes, order kinds, preview
synthesis (native/synthesized/none), fee summary, the ADAPTER's declared
endpoint vocabulary and data feeds (new DECLARED_ENDPOINTS/
DECLARED_DATA_FEEDS on AlpacaAdapter, derived from TRADING_HOSTS and
SUPPORTED_DATA_FEEDS), and the package version. Capability display only --
never key-presence inference (#233-aligned), no secret material anywhere
(the field set is closed and pinned). Front-ends: `keel brokers list`
(--json follows status --json's convention) and the TUI Venues browser
under Profile (`console.build_venues_lines`) -- the browser renders the
service's own shared wording (`brokers.capability_facts`), the SELECTED
adapter is highlighted and the active deployment's binding (config+db
pair, endpoint/data feed where the venue declares them) is named; the
two-front-ends-one-payload equality is pinned by test.

The glossary (O8): docs/glossary.md is the ONE hand-written home for
console term definitions -- seeded with the console's needed vocabulary
(rail, attestation + instrument attestation, exemption, screening,
promotion gate, paper/live mode, kill switch, autonomy, qabd, riba,
gharar, maysir/maisir, purification, session-bound venue, market clock,
trust window, DCA benchmark, granularity, trials ledger). The fiqh
terms' definitions are VERBATIM passages of docs/fiqh-basis.md with
their section citations, and gharar says "not stated" there exactly as
C3's shariah screen does -- pinned against the document, and pinned
equal to the shariah screen's own vocabulary so the surfaces cannot
drift. The TUI renders it bounded-read and mtime-cached (the research
readers' discipline); rule-PARAMETER help is never duplicated: the Help
menu's parameter view renders `rules.describe_params` -- the rule
classes' own docstrings, defaults and types, by introspection.

The contextual help registry (O8): every console module contributes its
screens' "what am I looking at" / "what will this do" rows (CONTEXT_HELP,
plain subject/description pairs kept WITH the owning module;
keel.commands.help_console is the registry and renderer), `?` opens the
current mode's overlay from EVERY console mode (pinned by a structural
scan of run_live's dispatch), and the Help menu becomes real: glossary,
screens & actions (the consolidated catalog), rule parameters, keys &
safety. The typed actions' help states the prompt cannot be pre-filled.

Fixes #394
@eaitbrahim
eaitbrahim merged commit ab252b0 into main Aug 19, 2026
5 checks passed
@eaitbrahim
eaitbrahim deleted the feat/394-brokers-help branch August 19, 2026 17:30
eaitbrahim added a commit that referenced this pull request Aug 19, 2026
…te contextual help (#407)

Thirteen adversarial-review findings on PR #406:

Blockers:
- bind ? in the discover overlay (the one dispatched mode without it);
  the every-mode structural test now extracts run_live's dispatch blocks
  by AST span, so the last block can no longer absorb the normal mode's
  ? handler and pass dishonestly
- glossary rail entry: eighteen guards (guards.py and fiqh-basis both say
  eighteen), and the Source line cites the rails table's true coverage
  (prudential rails 2-14, 16) with rails 1/17/18/19 as prose sections
- glossary promotion gate entry: the four floors (min_trades,
  min_expectancy, min_rr, min_win_rate) AND the PBO/degradation-slope
  conjunction; pooling stated as per-parameter-set, sample-size axis
  only, overfitting gate NOT pooled; the DCA comparison located in the
  simulate report, not the gate

Major:
- one raising adapter no longer kills the brokers listing: the service
  renders an honest error row (name + error, 78-col wrapped) and both
  front-ends (keel brokers list, the Venues browser) ride the same
  total service

Minor/nits:
- keys-&-safety rows state the C7 reality (h opens the Help menu, ?
  opens the context overlay, closes return to the Help menu) and the
  console menus are described as the live C3-C5 menus they are
- m closes the context-help overlay; ? opens it from the keys-&-safety
  screen too; dead profile_menu_venues_at wired into the live loop
- glossary autonomy/attestation sentences completed (attestation kept a
  verbatim contiguous fiqh-basis passage, twin-updated in the shariah
  screen's vocabulary)
- record-flow/reset-hwm help rows carry the cannot-be-pre-filled
  disclosure; screening and instrument attestation added to the
  verbatim fiqh pins; WIRED_FOR_DEPLOYMENT derived from the tracked
  configs' own broker.name selections as a drift guard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C7: venues/brokers visibility (service + CLI + TUI browser) and the newbie help & glossary system

1 participant