Repository navigation
fix(control-plane,mocactl): count completed turns, so sessions stop reporting 0 (#420) #672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -463,6 +463,11 @@ export function makeRuntimeReporter( | |
| } | ||
| await ready; | ||
| await index?.putRuntime(sessionId, fields); | ||
| // A completed turn is exactly the report that stamps turnEndedAt, so the count rides that | ||
| // rather than a flag of its own: no call site can report an end and forget to count it, and | ||
| // the counter cannot drift from the timestamp beside it (#420). Separate from the putRuntime | ||
| // above because it is an HINCRBY -- `turns` is never settable through the merging hSet. | ||
| if (fields.turnEndedAt !== undefined) await index?.bumpTurns(sessionId); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: The PR calls this a count of "completed" turns. In practice, every end-report site in |
||
| } catch { | ||
| // A transient failure (e.g. a Redis restart mid-rollout) must not permanently disable this | ||
| // reporter for the rest of the process's life: clear the memoised state so the NEXT call | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This comment and the test at
ownership.test.ts:310say this makesturnsunforgeable by "a compromised harness". But the harness is the tier that callsbumpTurns, over a Redis connection that canHSET/HINCRBYthe runtime key directly. So the allow-list stops well-behaved reporter code from setting an arbitrary value. It doesn't stop a compromised harness. That's the same limit as the existingownerallow-list, and display-only data makes it acceptable. Consider wording it as "the reporter cannot set it", so later readers don't treatturnsas trusted.