loop-engineering icon indicating copy to clipboard operation
loop-engineering copied to clipboard

loop-cost floors multi-day cadences to zero daily spend

Open lhy-dcf opened this issue 3 weeks ago • 0 comments

Proposed Title

[bug] loop-cost floors daily cadence rates, reporting zero spend for multi-day loops

Describe the bug

runsPerDayForInterval uses Math.floor(86400000 / intervalMs). Ordinary accepted inputs such as 2d and 7d therefore produce zero runs/day and zero daily token estimates in every scenario, despite nonzero per-run costs. Non-divisor intervals such as 7h also underestimate spend and can suppress a daily-cap warning.

This is distinct from merged #526, which rejects a zero-length interval (0m). The intervals here are valid and positive.

Steps to reproduce

On main 68ccc887ccf1e0cf3a1a1d787ce2da48f4959081:

node tools/loop-cost/dist/cli.js --pattern ci-sweeper --cadence 2d --level L2 --json
node tools/loop-cost/dist/cli.js --pattern daily-triage --cadence 7h --level L1 --json

Expected behavior

The operating guide describes cadence as a linear multiplier (docs/operating-loops.md, Token & Cost Budgeting). Because this estimates daily spend without accepting a schedule start time, the consistent interpretation is an average over repeated intervals: 2d = 0.5 runs/day, 7d = 1/7 runs/day, and 7h = 24/7 runs/day. This is an inference from the existing contract, not an explicit maintainer statement about averages; clarifying that wording in the package README would help.

For ci-sweeper, 2d, L2: full triage 50,000 tokens/run -> 25,000 tokens/day; realistic 19,250 tokens/run -> 9,625 tokens/day. Per-run estimates stay unchanged.

Actual behavior

2d and 7d: zero runs/day and zero daily spend. daily-triage, 7h, L1: full triage 150,000/day from 3 runs/day, rather than about 171,428.57/day from 24/7 runs/day (12.5% too low).

With a synthetic 650,000-token daily cap and action cost 200,000/run, 7h currently estimates 600,000/day without a cap warning; the daily average is about 685,714.29 and should warn.

Environment

Windows; Node v22.16.0; npm 10.9.2; @cobusgreyling/loop-cost 1.2.0; main at the commit above. Local real CLI subprocesses, no model/service credentials.

Proposed Scope

Remove flooring in the shared conversion, retain all per-run calculations and existing token rounding, add regression coverage for m/h/d intervals, ranges, scenario propagation, cap warnings and real CLI JSON; clarify averages versus calendar-day maximums. No parser grammar, dependency, scheduler, budget-runtime, hook or registry changes.

All-state searches for loop-cost and cadence, plus combined issue/PR searches for runsPerDay and fractional, found no equivalent report as of 2026-11-08 13:26:56 +08:00. AI-assisted investigation, executed locally. This file is a draft only; nothing was filed.

lhy-dcf avatar Nov 08 '26 05:11 lhy-dcf