Pull requests / #2400
#2400 Add opt-in usage accounting, output continuation and authenticated remote API
open · @QuickkApps · 0 comentários · No GitHub
BenchmarksSetup & installServer & APIAMD / HIPNVIDIA / CUDAModels & quantsSecurityDocumentationWindows
Descrição
## Title
Add opt-in usage accounting, output continuation and authenticated remote API
## Summary
Contribute the improvements developed in a local Strata installation as one requested bundle, rebased onto current upstream main (`296b59d`). Each feature is opt-in. The ordinary client output limits and terminal chat's 4096-token default remain unchanged.
## What changed
- Persistent server-side usage accounting across OpenAI Chat, Responses and Anthropic requests: input, output, cached input, cache hit percentage, time-weighted average and live/last decode speed, active model time, engine CPU time, GPU energy, average GPU power, API-equivalent value, electricity cost and estimated savings.
- A Usage tab with Today, selected-day and All-time views, editable prices and currency conversion, measurement coverage, daily history and shared app-bar figures. Cards use the requested 3-column order: API value / power cost / GPU energy; total / cached / cache hit; model active / prompt / output; CPU runtime / decode speed / average GPU power. Four-decimal formatting is confined to the existing status surface.
- Opt-in unlimited output continuation across finite native context windows. It retains the original prompt and recent generated text, keeps one stream/parser, respects cancellation, stop strings, thinking budgets and repetition protection, and counts the original input once. This is not infinite model memory.
- An authenticated loopback Node.js gateway and Windows Tailscale Funnel helpers, automatic startup/recovery while Strata runs, and an app-scoped idle-sleep guard. Only model/inference API routes are published, not UI, history or model-management routes.
- Fail-closed checks before publishing or disabling HTTPS port 443: additional, unrelated, malformed and foreground Tailscale handlers are not adopted or exposed. Gateway process reuse/stop checks both source and configuration paths.
- Regression coverage for ledger units, cache/decode accounting, idle/overlap energy, counter reset and missing readings, midnight splitting, persistence, long rollover/reasoning recovery, API streaming and remote ownership/recovery/default-off behavior. Stabilize the existing sleep-guard test so its instant mock cannot finish before the asynchronous hold is observed; production sleep-guard code is unchanged.
## Extra Notes
Related open proposals reviewed: #1876 and #1925 (Power-card energy/cost), #2204 (daily token/cost accounting), and #2370 (persistent usage statistics). This contribution uses its own UsageLedger format and Usage screen; those unmerged proposals are not silently combined with it.
### Enable explicitly
Add only the features wanted to `strata-<model>.json` and restart:
```json
{
"usage_tracker": true,
"unlimited_output": true,
"remote_access": true
}
```
Remote access requires Windows, Node.js, signed-in Tailscale with Funnel enabled, and Strata on loopback port 8080. Cloning the repository alone publishes nothing. Credentials are generated under the current user's protected local application-data directory; editor settings include that user's URL/key. See `remote-access/README.md`.
### Accounting and security limits
- Cached tokens are a subset of prompt tokens, not extra total tokens. Decode speed uses engine-decoded tokens and recorded decode time, excluding inserted control tokens, prefill, idle and untimed historical work.
- Energy uses NVML cumulative board-energy deltas where available and sampled-power integration otherwise, only over active work intervals. Missing readings retain unmeasured coverage. This is whole-board energy during the interval, not CPU/RAM/PSU energy or isolation from other GPU programs.
- API-equivalent value is a configurable benchmark, not a real bill. Price edits revalue history. Neither electricity tariffs nor currency exchange rates are fetched automatically.
- Treat a gateway key as trusted API access: any configured upstream MCP tools and local-image capabilities remain available. The watchdog cannot repair internet outages, forced sleep/shutdown, expired credentials or an unsupported editor provider.
- No personal run configuration, credentials, public hostname, usage ledger, prompts/history, screenshots, audit artifacts, models, native binaries or virtual environment are included.
### Verification
- 43 focused usage, rollover, remote and sleep-guard tests pass.
- Complete server suite: 822 tests, OK (15 environment-dependent skips). An existing instantaneous-mock sleep-guard test initially failed once; its test-only scheduling fix passes the complete rerun and 30 consecutive focused repetitions.
- Python correctness lint on touched modules, additional bug/simplification checks on new modules, JavaScript syntax and focused ESLint checks, CSS validation, PowerShell parsing and PSScriptAnalyzer pass.
- Remote ownership matrix also independently passes under Windows PowerShell, the helpers' actual runtime. Security review found no remaining publication blockers.
- No engine/kernel source changed. CUDA/HIP/SYCL builds, a full PC reboot and another device's editor end-to-end were not performed for this PR. Earlier live gateway checks in the local installation are documented separately; current regression tests do not modify a real tunnel.
No site
Links install, modelos, releases.