compliance: flag-gate AI portfolio + cloud sync + Stripe; de-risk prompts; harden reviewer
Implements docs/read-markets-compliance-changes.md as flag-gated changes (no deletions) so paused features stay in the tree for future re-enable. All four flags default False so a fresh deploy is compliance-safe. - New env flags: PORTFOLIO_AI_ENABLED, PORTFOLIO_SYNC_ENABLED, TICKER_UNIVERSE_AGGREGATE_ENABLED, SUBSCRIPTIONS_ENABLED. - Gates: /api/analyze, /api/portfolio/sync*, /api/stripe/*, /pricing, ticker_universe writes, portfolio_analysis.analyse(). is_paid_active() returns True for any auth'd user when subscriptions are paused. - Prompts (PROMPT_VERSION 10): universal _COMPLIANCE_RIDER prepended to every system prompt; watch list removed; price-target / close-above-below / trigger / forward-state-as-description rules added; SPECULATIVE pivoted to regime-only scenarios; daily + weekly digests tightened. - Reviewer: deterministic regex/lexicon pre-check fail-closed under the Haiku call; portfolio rider gated by PORTFOLIO_AI_ENABLED; base prompt sharpened for forward-state and MAR forward-opinion patterns; ReviewerVerdict audit table; generate_with_review retry helper. - Migration 0026: purge portfolio_sync + ticker_universe; create reviewer_verdicts. - Copy: MAR cite fixed to Art 3(1)(35) + Art 20 + Del Reg 2016/958; portfolio reframed as browser-only viewer in disclaimer / privacy / terms / about / pricing / landing (en + it). TODO(legal) marker for lawyer sign-off on disclaimer. - Tests: 13 lexicon + 6 reviewer compliance regressions; conftest enables all flags so existing 402 tests still cover their code paths. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
ee8384f1ba
commit
47dce1a1a4
38 changed files with 1188 additions and 279 deletions
|
|
@ -328,6 +328,10 @@ async def analyse(
|
|||
object is a function-local — when this function returns, the pie is
|
||||
garbage-collected. No DB writes mention positions."""
|
||||
s = get_settings()
|
||||
# Defense-in-depth: the route is already gated by require_flag, but a
|
||||
# direct service call must not bypass the compliance pause.
|
||||
if not s.PORTFOLIO_AI_ENABLED:
|
||||
raise RuntimeError("portfolio AI commentary is disabled")
|
||||
system, user = build_prompt(req)
|
||||
|
||||
review_cost = 0.0
|
||||
|
|
@ -372,7 +376,8 @@ async def analyse(
|
|||
# purpose of this surface, while keeping explicit
|
||||
# buy/sell/allocation directives forbidden.
|
||||
if llm is not None:
|
||||
verdict = await review_read(client, llm.content, surface="portfolio")
|
||||
verdict = await review_read(client, llm.content,
|
||||
surface="portfolio", session=session)
|
||||
review_cost = verdict.cost_usd or 0.0
|
||||
if not verdict.clean:
|
||||
status = "leaked"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue