Session audit counts the interventions this user actually makes - #488
Open
EdbertChan wants to merge 5 commits into
Open
Session audit counts the interventions this user actually makes#488EdbertChan wants to merge 5 commits into
EdbertChan wants to merge 5 commits into
Conversation
…aim: token_audit.py reports must-automate when a session carries two or more intervention-class slash commands, and reports its subagent totals as unchecked when a subagent transcript was written during the audit. Review lane: behavior Safety invariant: Read-only auditor. Existing counts and flags keep their meaning; the new intervention count is additive, and no regex over prose is introduced. Effectiveness measurement: Fixtures assert yes at two commands, no at one, and unchecked subagent totals when a subagent file is newer than the audit start. Slice rationale: One claim about one script's output. The dictionary that would let a checker notice the wording live is a separate change. Architectural effect: The auditor gains one input it already had on disk, the command-name field of user turns, and one honesty state for a section it used to print as complete. Goal: Make the must-automate flag see the interventions this user actually makes. Motivation: The flag read no while the user typed the automate command twice, so the automatic pass never fired. Alternative considerations: Matching phrases like "what do you mean" out of prose was rejected: the user has ruled out regex for meaning, and the typed command is an exact field. Lowering the existing thresholds was rejected as unrelated to the blind spot. Implementation details: Read engine/skills/reflect/scripts/token_audit.py and find where user turns are parsed and where the intervention kinds and the must-automate flag are computed. Add a count of user turns whose command-name field names an intervention-class command, starting with the automate and thrash commands, taken from the field rather than from message text. Report two or more as must-automate, alongside the existing kinds. Separately, record the audit start time, and when any subagent transcript file's modification time is at or after that time, print the subagent section as unchecked with the reason, rather than printing a total that was measured mid-write. Add fixtures and tests in engine/skills/reflect/scripts/tests/test_token_audit.py. Non-goals: No change to the existing frustration or thrash kinds, no change to pricing, and no new phrase dictionary in this slice. Layer: domain Feature state: active Files: - engine/skills/reflect/scripts/token_audit.py - engine/skills/reflect/scripts/tests/test_token_audit.py Change types: - engine/skills/reflect/scripts/token_audit.py: modify - engine/skills/reflect/scripts/tests/test_token_audit.py: modify Acceptance criteria: - `python3 -m unittest discover -s engine/skills/reflect/scripts/tests -v` exits 0. - `python3 scripts/check_no_new_comments.py --base origin/main` exits 0. Exit code: 0 Invoker-Finalize-Id: 49ca7364-a00f-459f-8545-1988c1672bd6
…: the reflect script tests, including the new intervention and unchecked-subagent cases, pass. Review lane: proof Safety invariant: Verification is read-only and changes no file. Effectiveness measurement: The unittest run is the measurement. Slice rationale: One proof for one claim. Architectural effect: None; verification only. Goal: Prove the auditor's tests pass. Motivation: A detector blind spot is only closed once a test pins it. Alternative considerations: The whole suite was rejected as slower without adding evidence for this claim. Implementation details: Run the reflect script tests. Non-goals: No edits. Layer: app_regression Feature state: active Acceptance criteria: - Exits 0 only when every test in that directory passes. Exit code: 0
…no ephemeral handoff files remain in the worktree. Review lane: cleanup Safety invariant: The scrub script only checks for known handoff artifact names and never touches source or tests. Effectiveness measurement: The script exits non-zero if any handoff artifact remains. Slice rationale: Required terminal scrub for every implementation workflow. Architectural effect: None; hygiene only. Goal: Leave the branch free of handoff artifacts. Motivation: Handoff files must not reach the PR. Alternative considerations: Manual cleanup was rejected as non-deterministic. Implementation details: Run scripts/scrub-handoff-artifacts.sh. Non-goals: No product edits. Layer: app_regression Feature state: active Acceptance criteria: - `bash scripts/scrub-handoff-artifacts.sh` exits 0. Exit code: 0
…a39149859-026dd462 — Review claim: no ephemeral handoff files remain in the worktree. Review lane: cleanup Safety invariant: The scrub script only checks for known handoff artifact names and never touches source or tests. Effectiveness measurement: The script exits non-zero if any handoff artifact remains. Slice rationale: Required terminal scrub for every implementation workflow. Architectural effect: None; hygiene only. Goal: Leave the branch free of handoff artifacts. Motivation: Handoff files must not reach the PR. Alternative considerations: Manual cleanup was rejected as non-deterministic. Implementation details: Run scripts/scrub-handoff-artifacts.sh. Non-goals: No product edits. Layer: app_regression Feature state: active Acceptance criteria: - `bash scripts/scrub-handoff-artifacts.sh` exits 0.
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_317d37e6-a160-4c71-8006-58af33aa24c4) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The session audit measures user signals and work performed so teams can decide when reflection or automation is needed.
Previously, typed intervention commands were invisible to the repeated-intervention signal, so two direct requests could pass without a must-automate flag.
Now, the audit counts intervention commands from structured user-turn fields and treats transcripts written during auditing as unchecked.
Review Claim
Approve counting repeated intervention commands and withholding partial subagent totals while their transcripts are still changing.
Review Lane
behavior
Review Unit
engine-runtime
Safety Invariant
The auditor only reads transcripts and prints a report; it writes nothing outside its own output file. Existing counts and flags keep their current meaning, and the new count is additive. No regex is added for meaning: the slash command is read as a field, not matched out of prose.
Assumption: this supplied safety invariant is treated as confirmed for this headless PR-body draft.
Slice Rationale
This slice changes one auditor and its focused tests. A phrase dictionary for meaning belongs in a separate change because it would introduce a different classification claim.
Non-goals
Architecture
Before
graph TD A["user transcript"] --> B["tone and intervention-kind analysis"] B --> C["must-automate flag"] D["subagent files"] --> E["totals printed as complete"]After
graph TD A["user transcript command-name fields"] --> B["intervention command count"] B --> C["must-automate flag"] D["subagent file modification times"] --> E["unchecked state when active"] E --> F["no combined total"]Test Plan
Test Plan
python3 engine/skills/make-pr/scripts/preflight.py --base origin/main—ok preflight passedpython3 -m unittest discover -s engine/skills/reflect/scripts/tests -v—Ran 204 tests in 40.857s;OKpython3 scripts/check_no_new_comments.py --base origin/main—ok no new commentsbash scripts/scrub-handoff-artifacts.sh—scrub-handoff-artifacts-okRevert Plan
Revert Plan
git revert <merge-commit-sha>.Note
Low Risk
Read-only transcript analysis with additive flags and conservative omission of combined totals when subagent files change mid-audit; no auth, billing, or persistence beyond existing audit JSON output.
Overview
The reflect token audit now treats explicit user slash commands as intervention signals, and it refuses to publish partial subagent totals while those transcripts are still being written.
Intervention commands: Claude sessions are scanned for human user turns containing structured
<command-name>markers for/automate-meand/thrash. Those counts are added to the frustration payload and folded intointervention-must-automate—two or more such commands trigger yes the same way repeated tone-based intervention kinds do. Flag rationales and console summaries now mentionintervention_commands=…. Subagent transcript paths are excluded from this scan.Subagent stability: At audit start,
audit_clauderecords a timestamp; if any subagentagent-*.jsonlis modified at or after that moment, subagent aggregation is markedunchecked,combined_totalis omitted (null),subagent-thrashis unchecked, and output explains which files were still active.Unit tests cover the 0/1/2 intervention-command thresholds and the mtime-based unchecked subagent path.
Reviewed by Cursor Bugbot for commit e6e92ad. Bugbot is set up for automated code reviews on this repo. Configure here.