-
Notifications
You must be signed in to change notification settings - Fork 0
Development #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Development #91
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1e2f884
fix: update baseline window logic and z-score threshold for improved …
dangerworm c0fa603
Merge branch 'development' of https://github.com/dangerworm/TornTools…
dangerworm 46440d5
feat(summaries): resize change-log summary buckets from 6h to 1h
dangerworm b729d1d
fix: improve formatting and clarity in session handoff and note to ne…
dangerworm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
.docker/flyway/sql/Versioned/V1.22__item_change_log_summaries_1h_buckets.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| -- Resize item_change_log_summaries buckets from 6h to 1h. Required for the | ||
| -- "Unusual activity" pivot's multi-horizon z-scores: at 6h buckets the 1h | ||
| -- and 6h windows would both collapse to "last bucket" with no intraday | ||
| -- resolution. | ||
| -- | ||
| -- Going to 1h directly (rather than 2h) so we don't have to re-bucket | ||
| -- again later if a finer horizon turns out to be useful. Storage cost is | ||
| -- ~1.2GB at 1-year retention on top of an empty start, well within the | ||
| -- B1ms 32GB budget. | ||
| -- | ||
| -- The bucket-size constant lives in DatabaseService.cs (SummaryBucketSeconds). | ||
| -- This migration must ship together with that change — a 6h-constant app | ||
| -- writing into a freshly-truncated 1h-intent table would happily produce | ||
| -- 6h-aligned rows again. | ||
| -- | ||
| -- After deploy, the existing SummariseChangeLogsAsync job backfills from | ||
| -- the earliest item_change_logs row (currently 2025-11-19). First run is | ||
| -- one-time long; subsequent runs are incremental. Trigger manually via | ||
| -- /hangfire to skip the 30-min wait. | ||
|
|
||
| TRUNCATE TABLE public.item_change_log_summaries; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,28 @@ | ||
| Hi Claude. Read context/session-handoff.md and context/note-to-next-instance.md before doing anything. | ||
| Hi Claude. Read context/session-handoff.md — the top "2026-04-24 end-of-session summary" block is the current state; the rest is historical narrative worth reading once but skimmable thereafter. | ||
|
|
||
| **Session of 2026-04-24 shipped a lot.** On development (and, after Drew releases this batch, main): | ||
| **Immediate state**: | ||
|
|
||
| - TODO quick-wins sweep (Torn market link, sortable tables, login refactor, polish). | ||
| - API key security phases 1+2+3 — at-rest AES-GCM, browser proxy, plaintext column dropped, dead code removed, Codex P1s addressed. | ||
| - Top Movers redesign first slice — median-window latest/baseline + per-item dispersion + z-scored ranking with min-move/min-z filters. Flyway V1.21 adds six new columns to `item_volatility_stats`. Widget switched to `move_z_score_1d`. Validated against a 550k-row data export before ship. | ||
| - Development/main: all Phase 1+2+3 security work + Top Movers redesign Phase 1 (including the sign-gate fix and the percentile_cont::numeric cast) shipped to prod. Drew verified the widget against real item charts. | ||
| - Uncommitted tweaks in the working tree (ItemVolatilityStatsRepository.cs + TODO.md): trimmed-median baseline + 2-day baseline buffer + z-score threshold raised from 1.0 to 1.5. Build clean. Drew will review and commit when he's back. | ||
|
|
||
| Uncommitted at time of handoff: the Top Movers redesign files plus the TODO/handoff updates. Everything builds clean (dotnet + tsc + npm run build). Drew will commit + deploy. | ||
| **Validated against Drew's data export**: these tweaks improve ranking noise filtering but don't fully eliminate the DSLR-Camera-style post-spike reversion. That's accepted as a known limitation because the next piece of work (the "Unusual activity" pivot) reframes the card so that reversion is a legitimate signal rather than misleading. | ||
|
|
||
| **Priorities in order for the next session:** | ||
| **Next piece of work: "Unusual activity" pivot**. | ||
|
|
||
| 1. If Drew hasn't already done so, verify the Top Movers Phase 1 deploy: wait for (or trigger via /hangfire) a RebuildVolatilityStats run, then eyeball the widget. Expected: Ski Mask gone, Scalpel/Edomondo noise, low-range items (Slingshot/Plastic Sword/Fine Chisel) mid-rank, real movers (Rope/Chain Whip/Cassock/Lubricant etc. in the 2026-04-24 snapshot) on top. | ||
| Drew wants to keep the risers/fallers cards but add an "unusual activity" framing for markets departing from their normal trends. With ~29 polling keys this is honestly what we CAN detect (vs top-N movers which we can't). Architecture sketch in the handoff: | ||
|
|
||
| 2. Top Movers remaining slices from the review (see TODO.md): | ||
| - (3) Volatility-bucket separation for naturally-noisy items. | ||
| - (4) "Most active" ceiling chip + secondary ranking key. | ||
| - (5) Confidence chips using stored sample counts. | ||
| - Drop legacy columns (current_price, price_change_1d, price_change_1w) once nothing reads them. | ||
| - Two-step pass: Hangfire writes an `item_unusual_candidates` shortlist; home-page endpoint joins against fresh data and re-scores cheaply. | ||
| - Multi-horizon z-scores (1h / 6h / 24h / 7d) against 30d baseline; "unusualness" = max |z|. | ||
| - "Why flagged" chip per row. | ||
| - Mode-to-nearest-1%-of-range as a display metric for item pages (not a ranking signal). | ||
|
|
||
| 3. Parked (need explicit sign-off): | ||
| - Read-only prod DB access for offline analysis. | ||
| - Cross-item spike correlation / event-calendar tool. | ||
| **Two open design questions Drew raised at end of session** (worth confirming before building): | ||
|
|
||
| **Data exports**: `data-exports/` (gitignored) holds the CSV dumps Drew provided during the Top Movers work. Five files from 2026-04-24 — summaries, items, current ivs, listings, foreign stocks. Useful reference if iterating on the ranking thresholds or the (3)-(5) slices. | ||
| 1. SQL in C# vs stored procedures — my vote: stay in C#. | ||
| 2. Shrink item_change_log_summaries buckets from 6h to 1h — my vote: yes, 1h. Needs a migration plan for existing data. This unlocks genuine intraday resolution for the multi-horizon pivot. | ||
|
|
||
| **Key ranking thresholds** (tune these if needed, knobs in ItemVolatilityStatsRepository.GetTopAsync): | ||
| - 10% minimum absolute move | ||
| - 1.0σ minimum absolute z-score | ||
| - 3 recent-window buckets minimum | ||
| - 10 baseline-window buckets minimum | ||
| - 14 days minimum for dispersion CV | ||
| **Do not** start building the pivot without Drew's go-ahead. It touches Flyway, a new table, the rebuild job, a new endpoint, and the widget. Plan first. | ||
|
|
||
| Data exports from 2026-04-24 are in `data-exports/` (gitignored) and were useful for validating ranking tweaks. Python + pandas works fine on the summaries CSV (~550k rows, 33MB). | ||
|
|
||
| Parked items needing explicit sign-off: read-only prod DB access; cross-item spike/event-calendar correlation tool. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
V1.22truncatesitem_change_log_summariesbut does not clearitem_volatility_stats, so right after migration the API can continue returning stale rankings computed from pre-migration data. This happens becauseRebuildStatsAsynconly upserts rows found in the last 7 days of summaries; when the source table is empty (or still backfilling), it updates nothing, andGetTopAsyncstill reads the old rows. Please invalidate/truncateitem_volatility_statsin the same migration (or gate reads by a freshcomputed_at) so users don’t see outdated 6h-bucket results during/after cutover.Useful? React with 👍 / 👎.