Skip to content

Session audit counts the interventions this user actually makes - #488

Open
EdbertChan wants to merge 5 commits into
mainfrom
plan/session-audit-counts-the-interventions-this-user-actually-makes
Open

Session audit counts the interventions this user actually makes#488
EdbertChan wants to merge 5 commits into
mainfrom
plan/session-audit-counts-the-interventions-this-user-actually-makes

Conversation

@EdbertChan

@EdbertChan EdbertChan commented Sep 12, 2026

Copy link
Copy Markdown
Owner

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

  • No change to existing frustration or thrash kinds.
  • No change to pricing.
  • No phrase dictionary or prose matching for meaning.

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"]
Loading

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"]
Loading

Test Plan

Test Plan
  • python3 engine/skills/make-pr/scripts/preflight.py --base origin/mainok preflight passed
  • python3 -m unittest discover -s engine/skills/reflect/scripts/tests -vRan 204 tests in 40.857s; OK
  • python3 scripts/check_no_new_comments.py --base origin/mainok no new comments
  • bash scripts/scrub-handoff-artifacts.shscrub-handoff-artifacts-ok

Revert Plan

Revert Plan
  • Safe to revert? Yes.
  • Revert command: git revert <merge-commit-sha>.
  • Post-revert steps: Rerun the focused unittest command and preflight checks.
  • Data migration? No.

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-me and /thrash. Those counts are added to the frustration payload and folded into intervention-must-automate—two or more such commands trigger yes the same way repeated tone-based intervention kinds do. Flag rationales and console summaries now mention intervention_commands=…. Subagent transcript paths are excluded from this scan.

Subagent stability: At audit start, audit_claude records a timestamp; if any subagent agent-*.jsonl is modified at or after that moment, subagent aggregation is marked unchecked, combined_total is omitted (null), subagent-thrash is 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.

Invoker and others added 5 commits September 12, 2026 07:05
…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.
@cursor

cursor Bot commented Sep 12, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant