You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[F1/F2] Position override UI — write to the qt stream with mandatory audit fields #26
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
Show the system vs qt portfolios side by side (that split is F1 — trade-ngin#47)
Let QT edit only the qt stream
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
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.
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.
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).
Activity
jrile018 commentedon Jul 26, 2026
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 theqtrow 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.Mandatory audit fields, as this issue requires
reasonis 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_appis stampedalgolens, anduser_idcomes from the JWT. Verified against a real PostgreSQL: an unqualifiedUPDATE ... SET reason='TAMPERED'andDELETE FROM trading.position_overridesboth left the data intact.Writes to the qt stream only
systemandbenchmarkare refused outright — supplyingportfolio_typeat 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 thesubscriber_*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
Dashboardfetches 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: falseuntil trade-ngin#56 publishes the risk envelope — honest about not checking, rather than reporting a pass.raohemdutt commentedon Oct 6, 2026
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.
raohemdutt commentedon Oct 16, 2026
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).