Skip to content

[F1/F2] Position override UI — write to the qt stream with mandatory audit fields #26

Closed

Description

@jrile018

Concept

AlgoLens becomes the interface QT uses to create/edit positions, replacing hand-editing the database.

Architecturally this is just another DB writer — per ADR-000 INV-1, all inter-service communication goes through TimescaleDB, so no new RPC path is needed. AlgoLens writes rows; trade-ngin's risk gate validates them.

What the UI must do

  1. Show the system vs qt portfolios side by side (that split is F1 — trade-ngin#47)
  2. Let QT edit only the qt stream
  3. Capture a required, non-empty reason on every edit — the ADR-000 C-5 trading.position_overrides audit table makes this non-negotiable, so the UI cannot allow a blank submit
  4. Surface the risk-gate result (risk_check_result) back to the user, including the breach case

Depends on

  • trade-ngin#47 (F1) — the portfolio_type schema must exist first
  • trade-ngin#48 (F2) — the risk-validation stage and position_overrides table
  • DECISION-1 (still open): hard-block vs audited-override determines whether the UI needs an explicit "override anyway" affordance at all

Note

Per ADR-000 C-3, AlgoLens' backend is permitted to write trading.position_overrides (inserts only) — this is the one carve-out from trade-ngin's ownership of the trading schema.

Refs: FEATURE_ANALYSIS_TRADE_NGIN_DATA_NGIN.md F1/F2, adr/ADR-000-cross-repo-contracts.md C-3/C-5, adr/ADR-003-algolens.md.

Activity

  1. jrile018 commented on Jul 26, 2026

    @jrile018
    ContributorAuthor

    Status: implemented — PR #31 (API, gate, audit) and PR #32 (UI). Not merged.

    Companion to trade-ngin#48. Full detail is there; this is the AlgoLens side.

    What exists now

    • POST /portfolio/positions — writes the qt row and its audit row in one transaction. If the audit insert fails, the position change rolls back with it.
    • GET /portfolio/overrides/<strategy_id> — the audit trail.
    • An editable positions table with a diff preview, a mandatory reason, an explicit risk-override step, and an override-history view that visually flags every edit which bypassed the gate.
    • The repo's first frontend test runner (vitest).

    Mandatory audit fields, as this issue requires

    reason is required and non-empty (rejected in the API before it reaches the DB CHECK, so the user gets a useful message rather than an IntegrityError), source_app is stamped algolens, and user_id comes from the JWT. Verified against a real PostgreSQL: an unqualified UPDATE ... SET reason='TAMPERED' and DELETE FROM trading.position_overrides both left the data intact.

    Writes to the qt stream only

    system and benchmark are refused outright — supplying portfolio_type at all is a 400. They are the baseline QT's discretionary alpha is measured against, and a baseline you can edit measures nothing.

    Three bugs caught in review worth recording

    No authorization. The endpoints originally had @jwt_required() only, which proves who you are, not that you may do this. Per ADR-000 C-6 the subscriber_* roles are external paying customers — any of them could have rewritten the fund's book. There is now a default-deny role gate; verified subscribers get 403 and write nothing. See #27.

    The post-save refresh did not refresh. It navigated "back" to force a reload, but Dashboard fetches with an empty dependency array and never unmounts. The edit would not have appeared — reading exactly like a failed save, on a book where the natural response is to make the edit again.

    The modal had no React key, so form state survived across positions. A reason typed for ES could be written into NQ's append-only audit row, which by design cannot be corrected afterwards.

    Dependency

    Requires trade-ngin migrations 001–004 (trade-ngin#54, #55) before it can run. The gate reports evaluated: false until trade-ngin#56 publishes the risk envelope — honest about not checking, rather than reporting a pass.

  2. raohemdutt commented on Oct 6, 2026

    @raohemdutt

    Status: Under review
    Waiting on: The QT platform review
    Next step: Dom: review
    Notes: Part of the QT platform, which is under review by Dom.

  3. raohemdutt commented on Oct 16, 2026

    @raohemdutt

    Done on main by AlgoLens #103, #108 and #109: the desk sees the model's book, its request and the final book, edits only its request with a required reason, and sees the engine's result and risk check (#133).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions