Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/binance-orderbook-trade-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ The geometry adapter checks the native `hasModel()` contract before reading pane

Every synchronous depth render creates a fresh geometry snapshot. Its 13-step inverse coordinate search memoizes native coordinate-to-price samples by the exact numeric coordinate, shared across that render's levels and initial validation samples. Search branches, precision, pixel-row ownership and cumulative quantities are unchanged. No sample survives into the next geometry, so zoom, logarithmic/inverted mode, and native scale changes are resampled. This removes repeated native calls at shared search-tree nodes without adding timers or caching depth prices/results. Invalid initial samples still reject the geometry; invalid intermediate search samples still throw.

Host synchronization passes its already-validated geometry directly into the
synchronous paint. A separately scheduled render still obtains a fresh geometry;
no snapshot is retained across frames or scale changes.

The userscript installs `core/binance-native-depth-source.js` at `document-start` and passively observes the native `/fapi/v1/rpiDepth?limit=1000` response and `{symbol}@rpiDepth@500ms` messages. It preserves Binance's original `fetch` result and WebSocket instances and never opens a second depth connection. `core/depth-profile-book.js` applies the observed `lastUpdateId`, `U`, `u`, and `pu` sequence contract and treats quantities as absolute values; zero removes a price level. The profile keeps every active price accumulated from the native stream and defers pixel-row aggregation to rendering, so distant levels are not discarded by the snapshot limit. Rendering remains sparse: a row is painted only when at least one real price level maps to that chart pixel. `core/depth-profile-session.js` only subscribes the active symbol to that page-owned source. A sequence gap waits for Binance's native resynchronization instead of issuing a userscript-owned retry request, while a changed private RPI contract fails the profile explicitly without blocking Binance's own request.

The session must stop and invalidate old work on symbol change, non-trading routes, hidden documents, and `pagehide`. The overlay canvas uses `pointer-events: none`; only its compact collapse control may receive pointer input. Do not connect this visualization book to ladder pricing or any trading decision.
Expand Down
4 changes: 2 additions & 2 deletions docs/binance-strategy27-events-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ V10 live projection. The VPS remains the only market-data and event-analysis
authority. The userscript opens no Binance market-data WebSocket, uses no
Binance API key, and does not recalculate the four force groups.

Version 0.6.3 retains this installation's private gateway configuration and
Version 0.6.4 retains this installation's private gateway configuration and
provides a shared read-only transport. Strategy29 owns its own summary panel,
lifecycle and panel position. The existing `strategy27GatewayOrigin` and
`strategy27GatewayAuthSecret` storage keys remain the single credential source;
Expand Down Expand Up @@ -165,7 +165,7 @@ ADR 032 in CorsairQuant owns the server-side rule and transport contract. The
browser does not reconstruct candidates from ordinary events or recalculate
market evidence. The client, lifecycle, panel, native chart layer and optional-job
controller are wired into the entrypoint and tested together. The source and
generated install artifact are version 0.6.3 with identical metadata headers.
generated install artifact are version 0.6.4 with identical metadata headers.
The generated artifact passes syntax, release-contract and isolated execution
checks, including candidate delivery, paired entities, clear and context stop.
Binance operator-page validation remains outstanding. Server/gateway rollout
Expand Down
5 changes: 4 additions & 1 deletion docs/binance-strategy29-bollinger-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ already-loaded native chart candles. The summary reads the authenticated
unified loopback gateway; it does not call Binance market-data or account APIs,
submit orders, rotate hidden charts, or add remote events as chart drawings.

Install Strategy29 0.5.3 with orderbook 2.7.199 or later, or use it alone.
Install Strategy29 0.5.4 with orderbook 2.7.199 or later, or use it alone.
Install CorsairQuant signal client 0.6.1 for the remote summary.
Do not combine it with the embedded observer in orderbook 2.7.198.
After updating/disabling the old script, reload the page. An embedded observer
Expand Down Expand Up @@ -166,6 +166,9 @@ latest snapshot. Rows are displayed and bounded by descending signal close time,
with descending durable sequence breaking ties. The snapshot response remains
sequence-ascending so the global increment contract is unchanged. Historical
backfills cannot evict newer signal times merely by being inserted later.
An empty increment advances the event-check timestamp without sorting retained
records or replacing their DOM rows. Nonempty increments sort once for retention
and rendering; locale changes still rebuild the translated rows.
This requires the server's explicit latest
query contract; a server rejecting it stops the remote context visibly.
Publish the V3 observer API contract before the client, then verify installed
Expand Down
132 changes: 132 additions & 0 deletions docs/userscript-performance-review.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Userscript Performance Review

Date: 2026-09-12. Baseline: `ee78e438f22e1c7d0f4317f8d5d563a8b2936292`.

## Scope and evidence

The review covers all eight repository-owned userscripts, their source entrypoints,
hot DOM paths, recurring work, and lifecycle cleanup. Generated artifacts were
checked against their sources, not edited independently. Third-party Tampermonkey
scripts and native Binance/TradingView/CMC application code are outside this scope.

The measurements below count actual calls and DOM operations in deterministic
fixtures. They are not estimates of live page CPU, memory savings, or latency.
The same synthetic inputs run against the baseline and current implementations.
Real Chromium fixtures also exercise the CMC layout and media-scanning changes.

## Audit coverage

| Script | Finding and outcome | Version |
| --- | --- | --- |
| Binance orderbook trade | Host synchronization measured depth geometry twice before one paint. The synchronous paint now consumes the first validated snapshot; independent frames still measure fresh geometry. | 2.7.206 |
| Binance trading data | The one-second age display reparsed and replaced three footer elements every tick. The panel creates those elements once and updates changed text only. | 1.1.16 |
| Binance CoinMarketCap data | Reviewed the 30-second refresh, five-second route watchdog, refresh epochs, drag listeners, and hidden/closed/non-trading cleanup. No comparable redundant hot path was established; behavior is unchanged. | 0.1.17, unchanged |
| Binance Strategy27 events | Each context tick discovered the same chart root twice. The target resolver now receives the root validated within that synchronous tick. | 0.6.4 |
| Binance Strategy29 Bollinger | Empty event increments sorted retained records twice and rebuilt up to 20 rows. Empty increments now update freshness without replacing rows; nonempty increments reuse one sorted list. | 0.5.4 |
| m3u8 downloader | One changed video/source caused a document-wide video scan. Mutation work now queues only affected videos and deduplicates them before the existing animation frame. | 0.10.38 |
| Auto refresh | Reviewed exact URL matching, the scheduled target and the 30-second missed-target check. No DOM scanning or expensive recurring work was found; scheduling is unchanged. | 1.0.10, unchanged |
| CoinMarketCap valuation helper | Every mutation batch read layout and ancestor text for every `span,p,div` before checking its label. Matching now precedes expensive checks, and batches share one scan per animation frame. | 0.2.9 |

Shared route patches remain idempotent, and route dispatch retains its existing
deduplication. TradingView marker ownership, full-history detection, native shape
audits, cooperative batch yields, and chart-save coordination remain unchanged.
Those checks protect current chart/session identity and require live profiling
before any further attempt to reduce their work.

## Operation counts

| Deterministic scenario | Baseline | Optimized |
| --- | ---: | ---: |
| CMC initial scan with two metric cards and 1,000 unrelated quote rows: layout reads | 6,020 | 8 |
| Same CMC document, ten mutation batches before the next paint: full text scans | 10 | 1 |
| Same ten CMC batches: layout reads / computed-style reads | 60,200 / 30,100 | 8 / 4 |
| One changed source among 100 videos: video scans | 100 | 1 |
| Same media mutation: document-wide video queries | 1 | 0 |
| Ten empty Strategy29 increments with 20 retained signals: list replacements | 10 | 0 |
| Same empty increments: newly created elements | 800 | 0 |
| Ten Strategy27 context ticks: chart-root queries | 20 | 10 |
| One orderbook host synchronization: native geometry snapshots | 2 | 1 |
| Sixty trading-data age updates: footer subtree replacements | 60 | 0 |

The first seven rows are reproduced by the standalone benchmark. The final three
are covered by source-entrypoint regression tests that were observed failing with
the baseline behavior and passing after the changes. Their assertions also check
displayed values, current client ownership, and fresh geometry on the next render.

## Preserved contracts

- CMC keeps the full text fallback scan so delayed nearby values, replaced labels,
and newly eligible cards remain discoverable. Only matching text reaches layout
checks; explainer-based matching and the top-left visibility boundary are intact.
Queued scans validate the current route when they execute.
- Media scanning still performs initial, DOM-ready, and load discovery. Added
nested sources resolve to their owning video. Removed videos, videos adopted
into another document, and picture-only sources do not enter the scan. Pending
videos are pruned during mutation delivery and checked again at frame execution.
XHR interception, URL deduplication, export persistence and queue semantics are
unchanged.
- Strategy29 still advances freshness and the client cursor on empty responses.
Locale changes rebuild translated rows; ordering, retention, cursor reset, and
nonempty event replacement retain their existing semantics.
- Each Strategy27 tick still validates visible-root uniqueness before resolving
the frame, native chart, exact symbol, and one-second interval. The historical
migration fixture remains frozen at its original API and version.
- Depth price-scale validation, logarithmic/inverted mapping, and coordinate
precision are unchanged. Geometry is reused only synchronously, never cached
across paints. Chinese and numeric symbols, including `龙虾USDT` and `4USDT`,
remain covered by real Chromium depth fixtures.
- Trading-data fetch frequency, server-time alignment, retry boundaries, and
visibility/close lifecycle are unchanged. Repeated footer updates in the same
second produce no DOM writes.

## Reproduction

Use the repository-supported Node runtime. The completed local verification used
Node 24.16.0.

```sh
node test/manual/userscript-performance-benchmark.mjs ee78e438f22e1c7d0f4317f8d5d563a8b2936292
node --test test/dom/coinmarketcap-valuation-helper.test.js test/dom/m3u8-media-scan.test.js test/dom/binance-trading-data-footer.test.js
node --test test/unit/binance-orderbook-trade/depth-profile-render-cycle.test.js
node --test test/dom/binance-strategy27-events/strategy27-entrypoint.test.js test/dom/binance-strategy29-bollinger/strategy29-summary-panel.test.js
npm test
npm run test:ui -- --reporter=line
```

The benchmark writes only its JSON report to stdout. Supplying a baseline revision
reads historical source through `git show`; it does not check out another branch.
The Strategy29 panel comparison uses unchanged current dependencies. The benchmark
stubs network requests and uses synthetic data only.

The new CMC browser fixture initially lacked a UTF-8 declaration and rendered
Chinese text as mojibake. The fixture now declares UTF-8 in both its response and
markup. This was a deterministic fixture defect, not a retry or suppressed failure.

Final validation completed:

- 1,017 unit/DOM tests passed; zero failures, cancellations, or skips.
- 80 Chromium tests passed with Playwright retries set to zero.
- All five affected generated bundles exactly match an in-memory rebuild from
current source, including metadata headers. All eight install scripts passed
syntax checks, and `git diff --check` passed.
- The CMC cards and Chinese/numeric-symbol depth screenshots were inspected in
isolated fixtures. Operation counts were rechecked after the media document
ownership regression was fixed.

Local evidence is under `test-results/userscript-performance/`: the before/after
operation counts, artifact hashes, final unit/browser output, verification totals,
and inspected screenshots. Release, public-artifact, and installation evidence is
recorded separately from these performance measurements.

## Verification limits

The performance measurements were collected in isolated fixtures. The live browser
attempt during implementation validation was blocked by the caller-identity policy.
Chromium fixture screenshots establish local rendering only, not live Binance or
CMC performance, and no logged-in Brooks export was exercised. Tampermonkey source
readback and post-reload loaded-source evidence are separate release checks; neither
can be inferred from the fixture results.

Independent read-only reviewers were requested but did not return a completed
verdict because model services returned rate-limit/unavailable errors. This review
gap remains explicit; passing automated checks is not an independent-review claim.
6 changes: 6 additions & 0 deletions docs/userscript-validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ by `docs/binance-strategy27-events-development.md`; Brooks/m3u8 behavior is owne
by `docs/brooks-media-sync-workflow.md`. Release and remote-publish mutations
are owned by `skills/userscript-release/SKILL.md`.

The eight-script performance audit, operation-count baselines, and reproduction
commands are recorded in `docs/userscript-performance-review.md`.

## Script Matrix

| Script | Editable source | Artifact | Focused checks | Detailed guide |
Expand Down Expand Up @@ -63,6 +66,9 @@ panel is closed, or the route is not a trading page. A route watcher may remain
alive while the panel is paused so a later SPA transition can restart the
business loop.

The one-second age display retains its footer elements and updates only changed
text. It does not recreate the timestamp row or alter the data-fetch schedule.

Each period fetch records which endpoint produced fresh data and which endpoint
used a cached value or has no value. Fresh and cached indicators remain distinct
when the panel computes directional votes. A stale request must not render into
Expand Down
Loading
Loading