You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
area:serverTouches the server areabugSomething isn't workingflakyA test that fails without a code cause; check these before treating a red check as yoursready-for-agentFully specified, ready for an AFK agent
apps/server/src/DevelopmentExecution.test.ts › "commits a callback-free mutation once per key and admits an action's nested mutation" failed on the test (24) job with no code cause. The PR only touched the CLI's refresh path. test (22) passed on the same commit, and test (24) passed on the two earlier runs of the same change.
The last assertion, assert.isAtLeast(tree[0]!.parent_ms, tree[0]!.child_ms) at line 315, got a parent db_ms of 2 and a child db_ms of 3.
The likely cause is rounding. runtime_invocations.db_ms is an INTEGER, while the measured times are fractional; the parent action's wide event in that run shows "dbMs":2.481965. The parent and child are measured and rounded separately, so at a few milliseconds a parent that only just covers its nested child can be stored below it. Comparing the unrounded values, or allowing a millisecond of rounding, would remove the race without weakening the "child time contributes to the parent" check.
Category: bug Summary: A nested invocation's db_ms can exceed its parent's because the database meter reads the clock separately for each ancestor
Current behavior:
Rounding is not the cause. Math.round is monotonic, so a stored parent of 2 with a child of 3 means the unrounded child (at least 2.5ms) really was larger than the unrounded parent (2.481965ms in the failing run).
The cause is in the analytics DatabaseMeter collector. When a reservation starts, Collector.start() reads the clock for the child and then calls the parent's start(), which takes its own later reading. On release, the child reads the clock and then releases the parent, which reads again. A GC pause or OS preemption between two of those readings gives the parent a shorter interval than the child when the start gap exceeds the release gap. The parent then records less than its child even after both reservations have closed.
Two independent traces (Opus 5.5 and GPT 6.1 Sol) confirmed the rest of the attribution chain is sound. The child's meter captures the parent's through capability.observe, every company-database reservation forwards to its ancestors, and in this fixture the child settles before the parent takes its reading. Replaying the real collector with a scripted clock that stalls 30µs between the child's and the parent's start readings gives child 2.51ms and parent 2.4801ms, stored as 3 and 2. That is the CI pattern.
This breaks the documented contract that a nested mutation's connection time contributes to the parent's db_ms. It also skews the stored invocation rows and quiet-query rollups by up to a GC pause per nesting level. The test failure is the symptom.
Desired behavior:
Each ancestor's metered interval for a reservation contains the descendant's interval: the ancestor starts no later and stops no earlier. A parent's db_ms therefore never falls below any child's for reservations that have closed, at any nesting depth and whatever stalls happen between clock readings.
Key interfaces:
DatabaseMeter.Collector.start(): start the parent's reservation before taking this collector's start reading. Keep the current release order: stop this collector first, then release the parent. The public Collector shape (start, the idempotent release it returns, and snapshot) does not change, and ConnectionTiming should need no edits.
The doc comment on DatabaseMeter.make should state the containment guarantee.
Acceptance criteria:
A focused test in the analytics package builds a parent and a child collector over a scripted, strictly increasing clock whose biggest gap falls between readings in start(). It asserts parent.snapshot() >= child.snapshot() after release. This test fails on the current code.
The same guarantee holds for a three-level chain (grandparent ≥ parent ≥ child).
The existing isAtLeast(parent_ms, child_ms) assertion in the dev-execution test "commits a callback-free mutation once per key and admits an action's nested mutation" stays unchanged; no tolerance is added.
Existing meter consumers' tests (company-database parent/child meter tests, runtime invocation tests) pass unchanged.
Out of scope:
Sharing one timestamp across all ancestors for exact equality. It would change the Collector interface, and containment is all the contract needs.
A killed or early-returning parent that takes its reading while a child is still running. The meter deliberately includes open reservations so a killed invocation need not wait for cleanup; changing that is a separate decision.
Storing db_ms as a fractional column, or any other change to how runtime_invocations stores durations.
area:serverTouches the server areabugSomething isn't workingflakyA test that fails without a code cause; check these before treating a red check as yoursready-for-agentFully specified, ready for an AFK agent
Activity
allisonmahmood commentedon Oct 2, 2026
Agent Brief
Category: bug
Summary: A nested invocation's
db_mscan exceed its parent's because the database meter reads the clock separately for each ancestorCurrent behavior:
Rounding is not the cause.
Math.roundis monotonic, so a stored parent of 2 with a child of 3 means the unrounded child (at least 2.5ms) really was larger than the unrounded parent (2.481965ms in the failing run).The cause is in the analytics
DatabaseMetercollector. When a reservation starts,Collector.start()reads the clock for the child and then calls the parent'sstart(), which takes its own later reading. On release, the child reads the clock and then releases the parent, which reads again. A GC pause or OS preemption between two of those readings gives the parent a shorter interval than the child when the start gap exceeds the release gap. The parent then records less than its child even after both reservations have closed.Two independent traces (Opus 5.5 and GPT 6.1 Sol) confirmed the rest of the attribution chain is sound. The child's meter captures the parent's through
capability.observe, every company-database reservation forwards to its ancestors, and in this fixture the child settles before the parent takes its reading. Replaying the real collector with a scripted clock that stalls 30µs between the child's and the parent's start readings gives child 2.51ms and parent 2.4801ms, stored as 3 and 2. That is the CI pattern.This breaks the documented contract that a nested mutation's connection time contributes to the parent's
db_ms. It also skews the stored invocation rows and quiet-query rollups by up to a GC pause per nesting level. The test failure is the symptom.Desired behavior:
Each ancestor's metered interval for a reservation contains the descendant's interval: the ancestor starts no later and stops no earlier. A parent's
db_mstherefore never falls below any child's for reservations that have closed, at any nesting depth and whatever stalls happen between clock readings.Key interfaces:
DatabaseMeter.Collector.start(): start the parent's reservation before taking this collector's start reading. Keep the current release order: stop this collector first, then release the parent. The publicCollectorshape (start, the idempotent release it returns, andsnapshot) does not change, andConnectionTimingshould need no edits.DatabaseMeter.makeshould state the containment guarantee.Acceptance criteria:
start(). It assertsparent.snapshot() >= child.snapshot()after release. This test fails on the current code.isAtLeast(parent_ms, child_ms)assertion in the dev-execution test "commits a callback-free mutation once per key and admits an action's nested mutation" stays unchanged; no tolerance is added.Out of scope:
Collectorinterface, and containment is all the contract needs.db_msas a fractional column, or any other change to howruntime_invocationsstores durations.