Repository navigation
Description
Part of #6074
Paths below are relative to plugins/session-flow/skills/audit-sessions/ unless they start with plugins/. Line numbers are on origin/main 9671ece.
Problem
E3. Thresholds are described as this machine's own baseline but ship as fixed numbers, and their recheck trigger has fired unreported (high).
SKILL.md:2("sweep it for sessions over this machine's own thresholds"),SKILL.md:101("The thresholds are this machine's own baseline, set inreference/sweep-rules.json"),SKILL.md:120("flags sessions over this machine's thresholds") andplugins/session-flow/README.md:219("against this machine's own thresholds") all say the thresholds belong to the user's machine.reference/sweep-rules.json:3says the opposite: "Thresholds are the per-session p90 of a 90-session spike on one machine (Claude Code 2.1.275-2.1.287, 2026-10-02)".scripts/sweep.py:33and:326load only the bundled rules file, and:131compares every session to the shipped constant. Every installer loads the same cached copy.reference/sweep-rules.json:5sets a recheck trigger ("the store's own p90 for a metric moves past its threshold by half"), but nothing computes it: sweep.py computes only medians (:120) and the report has no stale-baseline line.
S1 (standards). That trigger is deterministic arithmetic left to a person (discipline: script the deterministic work).
S4 (standards). The threshold basis cannot be re-checked from any source. "90-session" appears only in sweep-rules.json:3; scripts/tests/test_transcript_reader.py cites "spike signals.py:25-31", which is not in the repository; git log --all -S finds nothing else. reference/canaries.json:6 cites 104 sessions over the same version range, a different population.
S5 (standards). The Unchecked section recites the spike's numbers as if they described the user's store: sweep.py:129 appends f"reported only, no threshold: {rule['basis']}", so the report prints "spike 0.84" beside a store value of 0.79, and "33 of 90 sessions start with /clear" where that store had 346 of 764. The reasons still hold; the labeling is wrong.
Evidence
Verified this pass: all lines above at 9671ece (SKILL.md, sweep-rules.json and canaries.json unchanged since the audit commit cb30935).
Measured by the audit on one Windows 11 machine with 764 sessions, 2026-10-03 (not re-measured here). Reading the trigger one-sided (store p90 above 1.5x the threshold), it is met for three metrics:
| Metric | Store p90 | Threshold | Ratio |
|---|---|---|---|
tokens.sub |
252,476 | 72,347 | 3.49x |
hooks.stop_ms |
13,018 | 645 | 20.18x |
tools.interrupts |
1 | 0 | n/a (threshold 0) |
The trigger text does not say whether it is one-sided or two-sided, or what "by half" means for a threshold of 0.
Proposed approach
- Correct SKILL.md:2, :101, :120 and README.md:219 to say the thresholds are a shipped reference baseline, pointing at sweep-rules.json:3. Add a CHANGELOG entry.
- Pin the trigger arithmetic in sweep-rules.json:5: one-sided or two-sided, and how it applies to a threshold of 0.
- Have sweep.py compute each metric's store p90 (reuse collect.py's
_percentilerule, collect.py:159-163) and show it beside the threshold in both JSON and markdown, marking rows where the trigger is met. State in SKILL.md that the mark is advisory and leaves the exit code unchanged (SKILL.md:98 ties exit 1 to format drift only). Compute it on the interactive population once the classification child's E4 lands. This closes S1. - S4: commit the derivation's summary output beside sweep-rules.json (per thresholded metric: n, median, p90, population filter, Claude Code version range, date) and point sweep-rules.json:3 at it. Never commit the spike transcripts. Fix the canaries.json:6 population note so it names its own population.
- S5: label recited basis numbers in the Unchecked reason as the reference machine's (sweep.py:129), for example "reported only, no threshold (reference machine: ...)".
- When re-deriving the two thresholds the metric-accuracy child nulls (
hooks.stop_ms,time.active_s), use the new definitions.
Not recommended (scope review): per-machine thresholds derived from the user's own store. It hides costs every session shares, such as Stop hooks.
Files: SKILL.md, plugins/session-flow/README.md, reference/sweep-rules.json, reference/canaries.json, a new derivation summary file under reference/, scripts/sweep.py, scripts/tests/test_sweep.py, CHANGELOG and plugin.json.
Acceptance criteria
- SKILL.md and README.md no longer say the thresholds are this machine's own.
- sweep-rules.json:5 states whether the trigger is one-sided or two-sided and how it applies to a threshold of 0.
- The JSON and markdown reports show each metric's store p90 beside its threshold.
- On a fixture store where a metric's p90 exceeds 1.5x its threshold, that row is marked, and the sweep's exit code is unchanged by the mark.
- A committed file gives, per thresholded metric, n, median, p90, population filter, Claude Code version range and date, and sweep-rules.json:3 points at it.
- Each Unchecked reason that quotes basis numbers says they come from the reference machine.
Constraints and gotchas
- Land after the metric-accuracy child (new
hooks.stop_msand active-time keys) and the classification child (interactive population), or the p90 is computed on the wrong definitions and population. - Thresholds re-derived from a window that includes 2026-09-14 to 2026-09-27 on the audit machine would bake in a since-fixed harness-ops Stop hook cost; see perf(hooks): Stop and per-tool-call hook fan-out exceed budget on Windows (Stop p50 2.9 s, grows with session length) #4373 and PR perf(claude-ops): audit only transcript lines appended since last Stop #4192 for that cause.
- No new flag; if one is added it joins SKILL.md:25-27's accepted set.
- Version bump and CHANGELOG line per PR (AGENTS.md:20-22).
Context
Source: local handoff item 20261003-070338-session-flow-audit-sessions-accuracy-and-coverage.md (findings E3, S1, S4, S5). Related: #4373, PR #4192, #5925.
Activity
kyle-sexton commentedon Oct 4, 2026
This was generated by AI during work-loop.
Ratify autonomous dispatch of this C3 bug-fix item?
Classification:
work-class: scoped(C3), bug-fix-shaped. Intended dispatch: the work-loop worker lane, through/work-items:work, to a draft PR the lane never merges. The lane has not completed its first drain and no item-level ratification exists, so the item is queued here instead of dispatched. Ratify it through/work-items:attend-queue, and it returns to the frontier and dispatches on a later cycle.Lane: work-loop, instance melo-worker-1, cycle 1.
kyle-sexton commentedon Oct 4, 2026
kyle-sexton commentedon Oct 4, 2026
This was generated by AI during attend-queue.
Operator direction (2026-10-04): "go with the recommendations." This records that decision.
Operator ratification: ratified as C3 (scoped), blocked by #6075. This body says to land after #6075, which is still open. A native blocked-by edge now holds this item off the frontier until #6075 closes. #6076 has merged (PR #6179), so the interactive-population prerequisite is met.
Answers to the two open questions:
Notes:
Research: attend-queue slice
intake-6077.kyle-sexton commentedon Oct 4, 2026
New measurements for the
hooks.stop_msre-derivation, from the 2026-10-04 Windows performance audit (parent #6244). One machine, Claude Code 2.1.289, read-only; not re-run in this drafting pass. They confirm the stale baseline on a newer store and add one input the re-derivation needs.The current (summed) statistic. A collect plus bare sweep on 2026-10-04 reported
hooks.stop_mswith a median of 4,440 ms against the 645 ms threshold, and every one of the 481 sessions with Stop data over it, so the finding ranks nothing. This is still the summed definition (scripts/collect.py:421onorigin/main5779559; #6075 cited it at :412 before #6179 moved it). It is the median across sessions of each session's p90 of summed Stop durations.The max-based statistic #6075 moves to, on a different population. Over the newest 50 top-level transcripts (742
stop_hook_summaryrecords), taking the slowest hook per record: p50 848 ms, p95 4,837 ms, max 175,206 ms. Treat this as an indication, not a threshold: it is per record, not per-session p90, and covers 50 transcripts, not the interactive store.Weekly Stop wall time (max per record, all transcripts including subagents):
The W38-W39 driver was harness-ops "Checking for unsurfaced hook failures..." (p50 4,670 / 2,946 ms in W38 / W39, 252 ms in W40). This supports this issue's exclusion of 2026-09-14 to 2026-09-27.
New since the spike: the testing test-judge Stop hook ("Collecting the test judge's verdicts...", W40). On the newest 50 transcripts it ran p50 782 ms, p95 4,853 ms, max 175,206 ms (n = 721), the largest Stop contributor by total time. Any threshold derived from a window that includes W40 or later bakes in this hook. Decide on purpose whether the baseline should include it. Its long tail is the hook waiting up to 180 s for background judge runs; its separate turn-blocking on all-PASS verdicts was fixed by #6092.
Separately, the full re-read that a session-flow version bump forces on every collect is filed as its own issue, #6257.
Source: local handoff item 20261004-152632-claude-perf-audit-tooling-bugs.md, bug 4.
15 remaining items
melodic-automation-lanes commentedon Oct 25, 2026
The work-resolve-issue lane did not start this issue: it needs a person to make it clearer first.
Why, in the run's own words:
What the run says it did not do:
Run: https://github.com/melodic-software/claude-code-plugins/actions/runs/40190485006
To retry, answer the question here, remove
needs-humanand addagent-readyagain.kyle-sexton commentedon Oct 29, 2026
Host run. Re-collected this Linux (WSL) host's interactive session store with origin/main's collector into a copy, ran main's sweep over it, and computed the per-metric derivation numbers criterion 5 needs.
What ran
a6ab693b6, Claude Code 2.1.312, session-flow 1.10.1.pytest scripts/tests/test_sweep.py: 75 passed.collect.py collect --data-dir <copy> --retention-days 0over a copy of the store, so the live store was not touched. It re-read every transcript because the stored records were mostly collector 1.7.0. Wall time 257 s (18:44-18:48 UTC). Result: 2,468 records, 2,442 of them at collector 1.10.1.sweep.py --data-dir <copy>: statuspass, exit 0.PER_SESSION,p90andcensus.session_class. It was not committed.Acceptance criteria against origin/main
rechecksays one-sided, and that a threshold of 0 fires on any p90 above 0.stale_p90_factoris 1.5.p90, and the markdown has a p90 column (sweep.py:434). Also shown on real data in this run.tokens.subis markedbaseline_stale(p90 460,415 against 72,347) and the exit code stays 0.reference/. The numbers are below, but no thresholds were committed (see the open question).hooks.stop_msmax-basedactive_gap_s > wall_clock_sin 0 of 2,464 records.hooks.stop_msreadsstop_hooks.wait_ms_p90, the slowest hook per Stop run (sweep.py PER_SESSION), and 1,506 records have it.Derivation numbers (this host, not committed)
These are the numbers criterion 5's file needs. Population: interactive and unknown-entrypoint sessions (sweep's own filter), with session starts in 2026-09-14 to 2026-09-27 excluded. That leaves n = 660, starting 2026-09-28 to 2026-10-29, Claude Code 2.1.283-2.1.312, derived 2026-10-29. p90 uses sweep.py's
p90.This host's store holds no sessions before 2026-09-28. So it cannot split
hooks.stop_msinto before and after the testing test-judge Stop hook (W40): every session here includes it. It also cannot reproduce the reference machine's population (Windows, 2.1.275-2.1.287).Decision (agent, under the owner's stop rule: neither input changes intent or design)
hooks.stop_msincludes the test-judge Stop hook: it is a real per-stop wait, and this store cannot exclude it by window. Basis: the n = 569 row above.Remaining work (no host store needed): commit the derivation file under
reference/with the table above, pointsweep-rules.json:3at it, and set thetime.active_s,context.clear_commandsandhooks.stop_msthresholds from these p90 values. Criterion 5 then closes.Target labels: add agent-ready; remove host-run.
kyle-sexton commentedon Oct 30, 2026
Superseded: #9963 shipped the wording and the computed recheck trigger; the threshold derivation is tracked in #10223 and #10271.
kyle-sexton commentedon Oct 30, 2026
Host run. Re-collected this operator machine's interactive session store with the audit-sessions collector, derived per-metric n, median and p90 for every rule in
sweep-rules.json, and ran the sweep over the same store for the #6074 check.What ran
a955d6b58b; Claude Code 2.1.314 on the host. Run date 2026-10-30 (UTC).collect.py collect --retention-days 0 --excerpt-chars 0 --excerpt-words 0into a fresh condensed store (no excerpt text stored), run once: exit 0, 2,490 of 2,490 sessions ingested, redaction not failing closed, 221 s wall clock. The skill quotes about 70 s for 2.6 GB and sets a 300 s recheck trigger; this run was under that.sweep.py --format json, with no--write-report: exit 0, status pass, 710 sessions, 1,780 automated sessions set aside, 0 unclassified, no degraded metric, 0 canaries lost, 7 unknown record types (advisory).sweep.PER_SESSION,MACHINE_WIDEandPER_TICKETfor the extractors andcollect._percentilefor the p90 rule. With the date exclusion off, its n and p90 for all 12 metrics match the sweep'sdata.metricsexactly.Population
census.session_class), and 0 of them have an unknown entrypoint, so the strict-interactive figures are the same.Derivation (n = 672 sessions unless stated)
time.active_sreadstime.active_gap_s: record gaps capped at 300 s.hooks.stop_msis the median of each session's p90 Stop wait, read fromstop_hooks.wait_ms_p90.tokens.subbaseline_stale: its store p90 is above 1.5 times its threshold.hooks.stop_msincludes the test-judge Stop hook. The metric reads everyhookInfosentry and excludes no hook (collect.py:487-493). The store keeps no hook names, so this run cannot show how many sessions the test-judge hook ran in (UNVERIFIED). The 86 ms median is well below the 782 ms test-judge p50 measured on 2026-10-04, which suggests the hook fired in few of these sessions (UNVERIFIED).#6074 check, sweep over the re-collected store
collect.py:541). The strict comparison also gives 0, and so does the interactive population. For contrast, the oldturn_durationsum (time.active_s, still stored) is above wall clock in 56 records.hooks.stop_msreads the max-based per-Stop wait.sweep.py:111readsstop_hooks.wait_ms_p90, and the collector builds that from the slowesthookInfos[].durationMsof each Stop run (collect.py:493), not from the sum.active_over_wall,stop_wait_over_sum,usage_regressandsubagent_files_missingall held their expected absent state.Acceptance criteria
hooks.stop_msandtime.active_s: done, in the table above. This record is posted on chore(session-flow): derive the audit-sessions thresholds from a re-collected interactive store #10223 and fix(session-flow): call thresholds a shipped baseline and compute the recheck trigger #6077.hooks.stop_msincludes the test-judge hook: done. How often the test-judge hook ran in this population could not be shown (UNVERIFIED).hooks.stop_msread: done. The count is 0.No PR: the step changes no code. Slice 2 sets the thresholds from these p90s.
Target labels: add agent-ready; remove host-run.