Skip to content

Расход на пользователя ниже порога окупаемости: сжатие, дешёвый браузер, финмодель - #713

Merged
Ageree merged 21 commits into
bro-nextfrom
claude/bro-pricing-model-pfz07o
Nov 3, 2026

Conversation

@Ageree

@Ageree Ageree commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Что меняется для пользователя и расходов:

  • Длинные чаты сжимаются по умолчанию с порога 100 тыс. токенов: шаг Telegram стоит ~0,17 ₽ вместо 0,67 ₽ (кэш 87%).
  • Обрезка старых результатов выключена по умолчанию (HISTORY_TRIM_MODE=off): её сдвиг границы рвал кэш.
  • Быстрый режим браузера выключен по умолчанию (BROWSER_FAST_MODE=off): поручения чуть медленнее, но дешевле.
  • Карточки выключены по умолчанию (CARDS_MODE=off): send_card/update_card падали с «non-serializable capture».
  • Новые ops-скрипты: cost-per-user.sh, phone-minutes.sh.
  • Финмодель (docs/finmodel/bro-finmodel.xlsx) по данным прода: базовая прибыль ~500 ₽ на пользователя в месяц при N=200, безубыточно от ~83 пользователей.
  • Заметки для следующих сессий в docs/dev-notes.md.

Всё это уже выкачено на прод (версия 20261102-221454-ded027dd).

Проверки: тесты по затронутым наборам проходят; полный pnpm check не гонял.


Generated by Claude Code


Summary by cubic

Cuts per-user costs so spend drops below the subscription's payback threshold. Long chats now compress by default at 100k tokens (was 150k and off), and the fast browser, history trim, and cards are all off by default because they cost more than they save.

  • Compaction now applies to everyone unless COMPACTION_WORKSPACES=off and no longer skips turns when a few short context.* lines follow the opener: a Telegram step drops to ~0.17 ₽ from 0.67 ₽.
  • BROWSER_FAST_MODE, HISTORY_TRIM_MODE, and CARDS_MODE each default to off; the existing workspace lists no longer activate their pilot alone — set the variable to pilot to re-enable.
  • Adds cost-per-user.sh and phone-minutes.sh ops scripts and a live financial model in docs/finmodel/: base profit ~500 ₽ per user per month at N=200, break-even at ~83 users.

Written for commit 64e27ec. Summary will update on new commits.

View guided diff Turn on auto-fix

claude added 19 commits November 2, 2026 16:41
Сессия Telegram владельца росла до 390 тыс. токенов на шаг: сжатие
не срабатывало, а строки context.* после сообщения его отключали.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AXwerFzLYmqLGM4YVUf8zt
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AXwerFzLYmqLGM4YVUf8zt
BROWSER_FAST_MODE=off: список BROWSER_FAST_WORKSPACES больше ничего не включает.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AXwerFzLYmqLGM4YVUf8zt
…ороже, чем экономит

HISTORY_TRIM_MODE=off по умолчанию; живой пример: сдвиг границы на ходе
в Telegram читал 72k из 82k токенов без кэша (≈0,9 ₽).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AXwerFzLYmqLGM4YVUf8zt
@hacktron-app

hacktron-app Bot commented Nov 3, 2026

Copy link
Copy Markdown

Hacktron Security Check - Skipped

Reason: Code Review is not active for this organization

Start a free trial (no credit card required), subscribe, or add a payment method from organization billing settings

Go to: https://app.hacktron.ai/sthrip/billing

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a1d6d11d-e3cb-47af-90f3-d696c48c5c3c
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

15 issues found across 20 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/dev-notes.md">

<violation number="1" location="docs/dev-notes.md:531">
P3: This adds an internal VM hostname and a root-console access incident to the notes. AGENTS.md asks that notes skip internal hostnames and task history. Drop the hostname here, or refer to the host by role.</violation>

<violation number="2" location="docs/dev-notes.md:534">
P2: These notes expose the owner's session details and a specific search query (also line 2470); remove individual activity data and keep only non-user-specific operational results.</violation>
</file>

<file name="agent/lib/compaction/pilot.ts">

<violation number="1" location="agent/lib/compaction/pilot.ts:29">
P2: Unset `COMPACTION_WORKSPACES` now compacts for everyone, but the `env.ts` comment on this variable still says unset means "as before" near the model window. Update that comment and this function's JSDoc to state that unset means all and `off` means none.</violation>
</file>

<file name="agent/lib/compaction/tests/turn-start.test.ts">

<violation number="1" location="agent/lib/compaction/tests/turn-start.test.ts:85">
P2: Removing `context.state` and `context.instruction` from this list drops the only assertion that these kinds never compact when last. The doc comment in `turn-start.ts` still says a `context.*` message after the opener is unsafe, so the code, tests, and docs now disagree. Either restate the rule in the doc comment and keep a test for the new behavior, or keep these assertions.</violation>
</file>

<file name="shared/cards/pilot.ts">

<violation number="1" location="shared/cards/pilot.ts:9">
P2: `CARDS_MODE` only gates `cardsEnabled`. The card-answers channel and the cards schedule tick still check `CARDS_WORKSPACES` alone, so with `CARDS_MODE=off` they keep claiming and delivering queued card answers. Put the same `CARDS_MODE` check into those two call sites, or call `cardsEnabled` there, so the kill switch covers every card path. The doc comment above this function also still says only `CARDS_WORKSPACES` decides, so update it to mention `CARDS_MODE`.</violation>
</file>

<file name="tests/agent/browser-vm/runs.test.ts">

<violation number="1" location="tests/agent/browser-vm/runs.test.ts:679">
P3: This assertion pins `BROWSER_FAST_MODE: "off"` explicitly, so it does not check the default the comment names. Leave the variable unset, or assert against the schema default, so a change to the default in `shared/environment/env.ts` fails this test.</violation>
</file>

<file name="agent/lib/history/pilot.ts">

<violation number="1" location="agent/lib/history/pilot.ts:29">
P3: The JSDoc above `historyTrimPilot` still describes only `HISTORY_TRIM_WORKSPACES` as the switch. Add a sentence that the pilot also needs `HISTORY_TRIM_MODE=pilot`, otherwise the list is ignored.</violation>
</file>

<file name="docs/finmodel/README.md">

<violation number="1" location="docs/finmodel/README.md:7">
P2: The headline conclusion here (75–100 ₽/день makes 1 999 ₽ unprofitable at any N) is superseded by the 03.11 update below (tokens 25 ₽/день, ≈500 ₽ profit at N=200). Rewrite the 'Выводы' block for the current inputs, or mark it explicitly as the 26.10–02.11 snapshot so the two results don't read as contradictory.</violation>
</file>

<file name="agent/lib/compaction/turn-start.ts">

<violation number="1" location="agent/lib/compaction/turn-start.ts:46">
P2: The doc block above `compactsAtTurnStart` still says the opener must be the last message and that a `context.*` message after it could be all the recent part keeps. This function now accepts up to four such lines, so that comment is wrong. Update it to describe the four-line allowance and why the opener stays in the kept window.</violation>
</file>

<file name="scripts/cloudru-app-host/ops/cost-per-user.sh">

<violation number="1" location="scripts/cloudru-app-host/ops/cost-per-user.sh:6">
P3: The comment overstates the accepted input. The regex accepts only ISO-style dates with an optional time, so describe that format instead of 'dates or times PostgreSQL reads'.</violation>

<violation number="2" location="scripts/cloudru-app-host/ops/cost-per-user.sh:19">
P3: The script accepts `SINCE` after `UNTIL`, so the range predicates silently produce an empty report that looks like a valid zero sample. Add the `SINCE < UNTIL` check used by `usage-stats.sh`.</violation>

<violation number="3" location="scripts/cloudru-app-host/ops/cost-per-user.sh:34">
P2: These `days` CTEs count zero-cost unpriced rows as active days, lowering the reported cost per active day even when no cost was recorded. Filter zero-cost rows in both CTEs, or define the metric as usage days instead.</violation>

<violation number="4" location="scripts/cloudru-app-host/ops/cost-per-user.sh:42">
P2: The two 'without the most expensive person' figures exclude different people. The headline ranks by `per_day` and the by-source section ranks by `total`. Rank both by total, which matches the header's 'most expensive' wording, so the by-source split describes the same population as the headline.</violation>
</file>

<file name="scripts/cloudru-app-host/ops/phone-minutes.sh">

<violation number="1" location="scripts/cloudru-app-host/ops/phone-minutes.sh:16">
P3: The script accepts `SINCE` after `UNTIL`, so the range predicates silently produce an empty report that looks like a valid zero sample. Add the `SINCE < UNTIL` check used by `usage-stats.sh`.</violation>

<violation number="2" location="scripts/cloudru-app-host/ops/phone-minutes.sh:28">
P2: `provider_usd` sums `cost_usd` for every call, but GPT-Live also writes its billed estimate to that column; this overstates the ElevenLabs-only total. Exclude `live_` IDs or report the providers separately.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

// Unset means everyone: a long chat otherwise grows to hundreds of
// thousands of tokens a step (a Telegram session reached 388k, 05.11
// costs); `off` is the way back.
const list = env.COMPACTION_WORKSPACES ?? ["*"];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Unset COMPACTION_WORKSPACES now compacts for everyone, but the env.ts comment on this variable still says unset means "as before" near the model window. Update that comment and this function's JSDoc to state that unset means all and off means none.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At agent/lib/compaction/pilot.ts, line 29:

<comment>Unset `COMPACTION_WORKSPACES` now compacts for everyone, but the `env.ts` comment on this variable still says unset means "as before" near the model window. Update that comment and this function's JSDoc to state that unset means all and `off` means none.</comment>

<file context>
@@ -23,8 +23,13 @@ export async function compactionPilot(
+  // Unset means everyone: a long chat otherwise grows to hundreds of
+  // thousands of tokens a step (a Telegram session reached 388k, 05.11
+  // costs); `off` is the way back.
+  const list = env.COMPACTION_WORKSPACES ?? ["*"];
+  if (!directModelActive() || list.length === 0 || list.includes("off")) {
+    return false;
</file context>

});

it("never compacts the task agent's report, a retry or a context message last", () => {
it("never compacts the task agent's report, a retry or the checkpoint last", () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Removing context.state and context.instruction from this list drops the only assertion that these kinds never compact when last. The doc comment in turn-start.ts still says a context.* message after the opener is unsafe, so the code, tests, and docs now disagree. Either restate the rule in the doc comment and keep a test for the new behavior, or keep these assertions.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At agent/lib/compaction/tests/turn-start.test.ts, line 85:

<comment>Removing `context.state` and `context.instruction` from this list drops the only assertion that these kinds never compact when last. The doc comment in `turn-start.ts` still says a `context.*` message after the opener is unsafe, so the code, tests, and docs now disagree. Either restate the rule in the doc comment and keep a test for the new behavior, or keep these assertions.</comment>

<file context>
@@ -82,13 +82,11 @@ describe("whether a step may compact the conversation", () => {
   });
 
-  it("never compacts the task agent's report, a retry or a context message last", () => {
+  it("never compacts the task agent's report, a retry or the checkpoint last", () => {
     for (const kind of [
       "execution.background_task",
</file context>

Comment thread shared/cards/pilot.ts
* card, and the card's page before it takes an answer.
*/
export function cardsEnabled(scope: { readonly workspaceId: string }) {
if (env.CARDS_MODE !== "pilot") return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: CARDS_MODE only gates cardsEnabled. The card-answers channel and the cards schedule tick still check CARDS_WORKSPACES alone, so with CARDS_MODE=off they keep claiming and delivering queued card answers. Put the same CARDS_MODE check into those two call sites, or call cardsEnabled there, so the kill switch covers every card path. The doc comment above this function also still says only CARDS_WORKSPACES decides, so update it to mention CARDS_MODE.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At shared/cards/pilot.ts, line 9:

<comment>`CARDS_MODE` only gates `cardsEnabled`. The card-answers channel and the cards schedule tick still check `CARDS_WORKSPACES` alone, so with `CARDS_MODE=off` they keep claiming and delivering queued card answers. Put the same `CARDS_MODE` check into those two call sites, or call `cardsEnabled` there, so the kill switch covers every card path. The doc comment above this function also still says only `CARDS_WORKSPACES` decides, so update it to mention `CARDS_MODE`.</comment>

<file context>
@@ -6,6 +6,7 @@ import { env } from "@shared/environment";
  * card, and the card's page before it takes an answer.
  */
 export function cardsEnabled(scope: { readonly workspaceId: string }) {
+  if (env.CARDS_MODE !== "pilot") return false;
   const list = env.CARDS_WORKSPACES ?? [];
   return list.includes("*") || list.includes(scope.workspaceId);
</file context>

Comment thread docs/finmodel/README.md

Выводы при цене 1 999 ₽, постоянных 69,7 тыс. ₽/мес (курс 84,41), номере на каждого:

- Токены 75–100 ₽/день (2 250–3 000 ₽/мес) больше самой выручки: при них 1 999 ₽ не окупается ни при каком N. Цена для нуля при N=200 — 3,1–3,9 тыс. ₽.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The headline conclusion here (75–100 ₽/день makes 1 999 ₽ unprofitable at any N) is superseded by the 03.11 update below (tokens 25 ₽/день, ≈500 ₽ profit at N=200). Rewrite the 'Выводы' block for the current inputs, or mark it explicitly as the 26.10–02.11 snapshot so the two results don't read as contradictory.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At docs/finmodel/README.md, line 7:

<comment>The headline conclusion here (75–100 ₽/день makes 1 999 ₽ unprofitable at any N) is superseded by the 03.11 update below (tokens 25 ₽/день, ≈500 ₽ profit at N=200). Rewrite the 'Выводы' block for the current inputs, or mark it explicitly as the 26.10–02.11 snapshot so the two results don't read as contradictory.</comment>

<file context>
@@ -0,0 +1,38 @@
+
+Выводы при цене 1 999 ₽, постоянных 69,7 тыс. ₽/мес (курс 84,41), номере на каждого:
+
+- Токены 75–100 ₽/день (2 250–3 000 ₽/мес) больше самой выручки: при них 1 999 ₽ не окупается ни при каком N. Цена для нуля при N=200 — 3,1–3,9 тыс. ₽.
+- Нуль при 1 999 ₽: ≈42 ₽/день токенов при N=200, ≈30 при N=100, ≈50 при N=500. Маржа 30% при N=200 — ≈22 ₽/день.
+- Цена единиц в листе «Профили и лимиты» (голос, звонки, браузер) — допущения; сверять по `usage_costs` (`host.py ops <VM> usage-stats.sh`).
</file context>

(message) =>
message.role !== "user" || !userMessageKind(message).startsWith("memory.")
);
// Up to a few short `context.*` lines (location, tips, a recap) may follow

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The doc block above compactsAtTurnStart still says the opener must be the last message and that a context.* message after it could be all the recent part keeps. This function now accepts up to four such lines, so that comment is wrong. Update it to describe the four-line allowance and why the opener stays in the kept window.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At agent/lib/compaction/turn-start.ts, line 46:

<comment>The doc block above `compactsAtTurnStart` still says the opener must be the last message and that a `context.*` message after it could be all the recent part keeps. This function now accepts up to four such lines, so that comment is wrong. Update it to describe the four-line allowance and why the opener stays in the kept window.</comment>

<file context>
@@ -43,10 +43,24 @@ function userMessageKind(message: ModelMessage) {
-    (message) =>
-      message.role !== "user" || !userMessageKind(message).startsWith("memory.")
-  );
+  // Up to a few short `context.*` lines (location, tips, a recap) may follow
+  // the opener on a channel such as Telegram: eve keeps its last ten messages
+  // whole, so the opener stays beside them after the summary.
</file context>

await tunings({ BROWSER_FAST_WORKSPACES: "personal:another" })
).toEqual([{ flashMode: true, ...vmTuning }, vmTuning, vmTuning]);
// The list alone does nothing: the fast browser is off by default.
expect(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: This assertion pins BROWSER_FAST_MODE: "off" explicitly, so it does not check the default the comment names. Leave the variable unset, or assert against the schema default, so a change to the default in shared/environment/env.ts fails this test.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/agent/browser-vm/runs.test.ts, line 679:

<comment>This assertion pins `BROWSER_FAST_MODE: "off"` explicitly, so it does not check the default the comment names. Leave the variable unset, or assert against the schema default, so a change to the default in `shared/environment/env.ts` fails this test.</comment>

<file context>
@@ -675,6 +675,10 @@ describe("starting a run on a workspace's browser VM", () => {
       await tunings({ BROWSER_FAST_WORKSPACES: "personal:another" })
     ).toEqual([{ flashMode: true, ...vmTuning }, vmTuning, vmTuning]);
+    // The list alone does nothing: the fast browser is off by default.
+    expect(
+      await tunings({ BROWSER_FAST_MODE: "off", BROWSER_FAST_WORKSPACES: "*" })
+    ).toEqual([{ flashMode: true, ...vmTuning }, vmTuning, vmTuning]);
</file context>

turn?: Parameters<typeof pilotVerdictOfTurn>[1]
) {
const list = env.HISTORY_TRIM_WORKSPACES ?? [];
if (env.HISTORY_TRIM_MODE !== "pilot") return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The JSDoc above historyTrimPilot still describes only HISTORY_TRIM_WORKSPACES as the switch. Add a sentence that the pilot also needs HISTORY_TRIM_MODE=pilot, otherwise the list is ignored.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At agent/lib/history/pilot.ts, line 29:

<comment>The JSDoc above `historyTrimPilot` still describes only `HISTORY_TRIM_WORKSPACES` as the switch. Add a sentence that the pilot also needs `HISTORY_TRIM_MODE=pilot`, otherwise the list is ignored.</comment>

<file context>
@@ -26,6 +26,7 @@ export async function historyTrimPilot(
   turn?: Parameters<typeof pilotVerdictOfTurn>[1]
 ) {
   const list = env.HISTORY_TRIM_WORKSPACES ?? [];
+  if (env.HISTORY_TRIM_MODE !== "pilot") return false;
   if (!directModelActive() || list.length === 0) return false;
   if (list.includes("*")) return true;
</file context>

#
# host.py ops NAME cost-per-user.sh [SINCE [UNTIL]]
#
# SINCE and UNTIL are dates or times PostgreSQL reads; SINCE defaults to fourteen days ago, UNTIL to now.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The comment overstates the accepted input. The regex accepts only ISO-style dates with an optional time, so describe that format instead of 'dates or times PostgreSQL reads'.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At scripts/cloudru-app-host/ops/cost-per-user.sh, line 6:

<comment>The comment overstates the accepted input. The regex accepts only ISO-style dates with an optional time, so describe that format instead of 'dates or times PostgreSQL reads'.</comment>

<file context>
@@ -0,0 +1,87 @@
+#
+#   host.py ops NAME cost-per-user.sh [SINCE [UNTIL]]
+#
+# SINCE and UNTIL are dates or times PostgreSQL reads; SINCE defaults to fourteen days ago, UNTIL to now.
+# Prints aggregates only — counts, percentiles and shares — never a workspace id or anything a person wrote.
+# Roubles are what usage_costs holds (model, browser model, VM share, proxy); the browser VM's powered-on
</file context>
Suggested change
# SINCE and UNTIL are dates or times PostgreSQL reads; SINCE defaults to fourteen days ago, UNTIL to now.
# SINCE and UNTIL are ISO dates or times (YYYY-MM-DD, optionally THH:MM[:SS] with Z or a ±HH:MM offset); SINCE defaults to fourteen days ago, UNTIL to now.

SINCE=${1:-$(date -u -d '30 days ago' +%Y-%m-%dT%H:%M:%SZ)}
UNTIL=${2:-$(date -u +%Y-%m-%dT%H:%M:%SZ)}
shape='^[0-9]{4}-[0-9]{2}-[0-9]{2}([T ][0-9:.]+(Z|[+-][0-9:]+)?)?$'
for value in "$SINCE" "$UNTIL"; do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The script accepts SINCE after UNTIL, so the range predicates silently produce an empty report that looks like a valid zero sample. Add the SINCE < UNTIL check used by usage-stats.sh.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At scripts/cloudru-app-host/ops/phone-minutes.sh, line 16:

<comment>The script accepts `SINCE` after `UNTIL`, so the range predicates silently produce an empty report that looks like a valid zero sample. Add the `SINCE < UNTIL` check used by `usage-stats.sh`.</comment>

<file context>
@@ -0,0 +1,61 @@
+SINCE=${1:-$(date -u -d '30 days ago' +%Y-%m-%dT%H:%M:%SZ)}
+UNTIL=${2:-$(date -u +%Y-%m-%dT%H:%M:%SZ)}
+shape='^[0-9]{4}-[0-9]{2}-[0-9]{2}([T ][0-9:.]+(Z|[+-][0-9:]+)?)?$'
+for value in "$SINCE" "$UNTIL"; do
+  [[ "$value" =~ $shape ]] || die "not a date or time: $value"
+done
</file context>

SINCE=${1:-$(date -u -d '14 days ago' +%Y-%m-%dT%H:%M:%SZ)}
UNTIL=${2:-$(date -u +%Y-%m-%dT%H:%M:%SZ)}
shape='^[0-9]{4}-[0-9]{2}-[0-9]{2}([T ][0-9:.]+(Z|[+-][0-9:]+)?)?$'
for value in "$SINCE" "$UNTIL"; do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The script accepts SINCE after UNTIL, so the range predicates silently produce an empty report that looks like a valid zero sample. Add the SINCE < UNTIL check used by usage-stats.sh.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At scripts/cloudru-app-host/ops/cost-per-user.sh, line 19:

<comment>The script accepts `SINCE` after `UNTIL`, so the range predicates silently produce an empty report that looks like a valid zero sample. Add the `SINCE < UNTIL` check used by `usage-stats.sh`.</comment>

<file context>
@@ -0,0 +1,87 @@
+SINCE=${1:-$(date -u -d '14 days ago' +%Y-%m-%dT%H:%M:%SZ)}
+UNTIL=${2:-$(date -u +%Y-%m-%dT%H:%M:%SZ)}
+shape='^[0-9]{4}-[0-9]{2}-[0-9]{2}([T ][0-9:.]+(Z|[+-][0-9:]+)?)?$'
+for value in "$SINCE" "$UNTIL"; do
+  [[ "$value" =~ $shape ]] || die "not a date or time: $value"
+done
</file context>

@Ageree
Ageree merged commit b745e80 into bro-next Nov 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants