Skip to content

refactor(session-flow): simplify audit-sessions census, collect and friction_scan - #15160

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14747-42883503336-1
Nov 10, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14747-42883503336-1

Conversation

@melodic-automation-lanes

@melodic-automation-lanes melodic-automation-lanes Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #14747

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Applied small cleanups inside each of the three audit-sessions scripts, with no behavior change. A value that was computed or looked up more than once is now held in a local: the store path in census.load_records, the newest-version count in census.drift, the command text in friction_scan.tool_shape, the message in FrictionScan._assistant, the permission-denied test in FrictionScan._tool_result, and the stop-hook sum and max in SessionScan._system. A single-use alias in collect.build_record is gone. Nothing moved between files and nothing was deduplicated across files, since the issue leaves that to the later restructuring pass. As with any edit to these files, the change alters the COLLECTOR_INPUTS digest, so the next collect run re-ingests every stored session; that is the documented effect of any change to these files, not a change in what they do.

Not verified

  • The Python test suites (audit-sessions scripts/tests, audit-friction scripts/tests) were not run, because this lane cannot run an interpreter. They are left to the PR's CI.
  • Tidy did not run every pass in full. Its ai-slop pass could only read the changelog fragment against the rubric by hand, because this lane's Bash cannot run the ai-slop detect.sh. The hand read found no tells. The simplify, comment and residue passes ran and found nothing more to change.
  • Build and lint (ruff or a py_compile pass) could not run here, because this lane allows no interpreter. Left to the PR's CI.
  • ci-status green on the PR: a PR CI check, left to the PR's CI.

Fix

  • plugins/session-flow/skills/audit-sessions/scripts/census.py: load_records computes store_dir once; drift computes the newest-version count once for the new class check and its row.
  • plugins/session-flow/skills/audit-sessions/scripts/collect.py: the stop_hook_summary branch keeps the hook sum and max in locals instead of reading them back from the lists; build_record drops the single-use suppressed alias for redactor.fail_closed.
  • plugins/session-flow/skills/audit-sessions/scripts/friction_scan.py: tool_shape reads the command once and splits it once; _assistant reads the message once; _tool_result computes denied once and uses it in the next_ok, AskUserQuestion reply and denied-event branches.
  • .changes/session-flow/work-resolve-issue-issue-14747-42883503336-1-9c851478.md: new patch fragment, ### Changed with "Internal simplification, no behavior change."

Verification

The runner ran each check from the base copy against 980faf4:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • check-changelog-fragments: all 3 fragments under .changes/ valid (run before and after tidy).
  • check-changed-skills: audit-sessions PASS, 0 errors, 2 pre-existing SKILL.md size warnings unrelated to this change (run before and after tidy).
  • check-affected: 13 passed, 6 skipped, the rest CI only, over 4 changed files (run before and after tidy).
  • Fresh-context review subagent over the whole diff: no findings. It confirmed tool_input is always a dict at both tool_shape call sites, permission_event returns None or a dict that always has outcome, Redactor.fail_closed cannot change during build_record (a property over the frozen dataclass's…
  • Diff size: 3 code files plus 1 fragment, about 40 changed lines, all in the session-flow area.
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42883503336

Left out: the items under Not verified.

Related

#14747

Merge-Risk: max=MEDIUM demote=false head=980faf42fda3a5f6665acc58076ef7db7d7deda5 rubric=8.3.5 rater=claude-opus-5-5 checker=claude-opus-5-5

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 980faf42fda3a5f6665acc58076ef7db7d7deda5: read 4 of 4 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15160

I found no security issues in this change.

I read every hunk of all 4 changed files. None of them matches a trusted-path glob, and the diff touches no trust control, plugin manifest, workflow or standing instruction.

What the change does: it refactors three local analysis scripts in plugins/session-flow/skills/audit-sessions/scripts/ and adds a patch changelog fragment. I checked each hunk to confirm that what it does and what data it emits are unchanged:

  • census.py
    • load_records now computes store_dir(data_dir) once and keeps it in a local, so the path and the glob are the same as before.
    • drift stores count(newest, model, key) in a local. The condition and the row it builds are the same.
  • collect.py
    • The stop-hook sum and max are kept in locals. Both lists get the same values, and the invariant check compares the same two numbers.
    • excerpts_suppressed now reads redactor.fail_closed directly. Nothing between the removed alias and this read changes it, so the redaction fail-closed flag the record reports does not change.
  • friction_scan.py
    • tool_shape: lines[0] if lines else None matches the old command.strip() truthiness test. A stripped non-empty string always has a first line, and an empty one yields []. The target text an excerpt may show does not change.
    • _assistant: it reads message once, with the same dict guard.
    • _tool_result: denied is now permission is not None and permission["outcome"] == "denied", which replaces the truthiness test on permission. The two differ only for an empty dict, and in that case the old code would already raise KeyError at the unchanged permission["outcome"] read further down. The change opens no new path.

There is no new input handling, subprocess, path construction, network call or credential use. The redaction and scrubbing paths (Scrubber, redactor) are untouched apart from the alias removal.

The PR context contains no embedded text addressed to this lane.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 980faf42fda3a5f6665acc58076ef7db7d7deda5: read 4 of 4 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

I read all 4 changed files in full (3 audit-sessions scripts plus 1 changelog fragment) and checked each edit against the base behaviour it replaces. Every rewrite keeps the old behaviour.

  • census.py
    • load_records: store_dir is a pure path builder (census.py:69), so calling it once returns the same path the two separate calls did.
    • drift: the old and chain already evaluated count(newest, model, key) first. count only reads data and changes nothing, so moving that call into newest_count before the if changes nothing.
  • collect.py
    • The new wait > total test compares the same two values the old [-1] reads got from the lists, which were appended just before.
    • Dropping suppressed reads redactor.fail_closed later in build_record. That is still safe: Redactor is @dataclass(frozen=True) (redact.py:103), fail_closed is a property computed from skipped and rules, and nothing writes to either after load builds it.
  • friction_scan.py
    • tool_shape: after strip(), a non-empty string always gives a non-empty splitlines(), and an empty one gives []. So lines[0] if lines else None matches the old result.
    • _assistant: reading message once is the same check.
    • denied: transcript_reader.permission_event returns either None or a dict that always has outcome (transcript_reader.py:330-346). So permission is not None and … is equivalent to the old permission and … in a boolean context. Every place that used the result (next_ok, the AskUserQuestion reply, the denied branch) treats it as true or false.
    • The chained conditional "rejected" if denied else "approve" if … else "other" groups from the right, so it matches the old nested form.

Closing issue #14747 acceptance criteria

  • Behaviour unchanged: met, by the reasoning above.
  • Only the listed files plus a fragment are edited: met.
  • Within 400 lines and 15 files: met (about 40 lines).
  • The fragment is bump: patch with ### Changed and the exact text "Internal simplification, no behavior change.": met.
  • ci-status green: CI hasn't run yet, so I can't confirm it from here.

Verification

  • The PR body says the Python tests, ruff and py_compile did not run. I didn't run them either, so this review rests on reading the code, not on executing it.
  • Changing these files changes the COLLECTOR_INPUTS digest, so the next collect run re-ingests every stored session. That uses local compute only and is the documented effect of any edit to these files.

I found no embedded instructions in the PR context, and no prior findings apply.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 980faf42fda3a5f6665acc58076ef7db7d7deda5, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 980faf4

The verifier passed this head. The capture artifact holds the capture summary, which says whether the capture ran, and any screenshot or video that passed the mask check; this comment uploads no file.

Capture artifact: pr-capture-15160-980faf42fda3a5f6665acc58076ef7db7d7deda5, expires on 2026-12-10.

One comment per pull request, updated in place for each new head.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit 3e1e9fe Nov 10, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14747-42883503336-1 branch November 10, 2026 20:53
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 5, survived 2, timeout 0, no coverage 0, invalid 0, not run 0.
Covered-code score 71%; mutation score 71%.

File Killed Survived Timeout No coverage Invalid Not run
plugins/session-flow/skills/audit-sessions/scripts/census.py 2 0 0 0 0 0
plugins/session-flow/skills/audit-sessions/scripts/collect.py 2 0 0 0 0 0
plugins/session-flow/skills/audit-sessions/scripts/friction_scan.py 1 2 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/session-flow/skills/audit-sessions/scripts/friction_scan.py:147 other productive no-assertion
plugins/session-flow/skills/audit-sessions/scripts/friction_scan.py:329 LCR productive input-gap

The run's summary has the full report.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 3e1e9fe04201e29f8149bc83732d283503795481; later checks count it verified from this comment.

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.

Simplify the audit-sessions session-flow plugin code

0 participants