Skip to content

refactor(session-flow): simplify audit-friction friction.py - #14880

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14746

Summary

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

Simplified plugins/session-flow/skills/audit-friction/scripts/friction.py without changing what it does. A private _cell helper now does the markdown pipe escaping that four tables each wrote inline (two spelled with chr(92)). parse_rules strips the rule text once and uses an early continue instead of nested ifs. cause_hint returns the cause directly for 'classifier' and 'hook'. A dead 'if records else 0' guard in aggregate is gone, since rows exist only when records is non-empty. Outputs, exit codes, written files, CLI flags and existing names are unchanged for every store the collector writes. One edge case changed: if a hand-edited store holds a non-string next_tool, markdown rendering used to crash with AttributeError and now prints str(value). The collector always writes a string or None there (friction_scan.py:261,268,346).

Not verified

  • pytest suites tests/test_friction.py and test_friction_duplicates.py were not run, because this lane can run no interpreter; left to the PR's CI
  • No Python lint or compile run (no interpreter available); the reviewer checked f-string quoting for Python 3.10 by reading the code; left to the PR's CI
  • tidy: markdown passes 4 and 5 skipped because the fragment's only line is text the issue requires verbatim; pass 2's docstring deletion was not made because change-shape.sh cannot run in this lane
  • Untracked dotfiles in the checkout root (.bashrc, .bash_profile, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) are not part of this change; this run did not create them and they should not go into the patch

Fix

  • plugins/session-flow/skills/audit-friction/scripts/friction.py: added the private _cell helper and used it in render_mine, cmd_cause and cmd_diff; flattened parse_rules; merged two cause_hint branches; removed a dead guard in aggregate
  • .changes/session-flow/work-resolve-issue-issue-14746-42704524105-1-d0c9848d.md: patch fragment, '### Changed' with 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against dfd6528:

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

The run reports:

  • check-changelog-fragments: all 29 fragments valid (run before and after tidy and review)
  • check-changed-skills: audit-friction PASS, 0 errors, 1 warning that predates this change (SKILL.md body 187 lines, unchanged by this diff)
  • check-affected: 13 passed, 6 skipped, over 2 changed files
  • fresh-context review subagent, reading code only: no behavior change for any input the collector can write; the only difference is the non-string next_tool case on a hand-edited store; read both test files and found nothing they assert that the change breaks
  • code-tidying:tidy-diff over the 10 changed hunks: no edits; one proposal (the docstring on private _cell repeats its body; the deletion was not made because change-shape.sh cannot run in this lane)
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42704524105

Left out: the items under Not verified.

Related

#14746

Merge-Risk: unrated reason=no-rating

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

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Security review: PR #14880 (head dfd6528)

I found no security issues. I read every hunk of both changed files.

  • plugins/session-flow/skills/audit-friction/scripts/friction.py: this is a local refactor of the report script.
    • A new private helper, _cell, now does the markdown pipe escaping that four tables each did inline. Every table that escaped pipes before still escapes them the same way, so no table cell lost its escaping.
    • The other changes keep the same behaviour: parse_rules uses an early continue instead of nested ifs, two cause_hint branches are merged into one, and an unreachable if records else 0 guard in aggregate is gone.
    • The only behaviour change is the edge case the PR describes: a non-string next_tool value in a hand-edited store now prints as str(value) instead of crashing. That opens no injection path.
    • The change adds no subprocess, file path, network or credential handling.
  • .changes/session-flow/...d0c9848d.md: a changelog fragment, text only.

Neither file matches a trusted-path glob. The diff touches no trust control, merge hold, workflow, plugin manifest or standing instruction. It is eligible for skip-gate item 2 (no security-relevant surface).

The PR description lists untracked dotfiles in the lane's checkout root, .mcp.json among them. None of them are in this diff, so they are outside this review's scope.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Code review: PR #14880, refactor(session-flow): simplify audit-friction friction.py

No findings. I read every hunk in both changed files. Neither file is on a trusted path.

What I checked

  • _cell helper (friction.py:101): it replaces four inline pipe escapes in render_mine, cmd_cause and cmd_diff, two of which were spelled with chr(92). For string input the output is the same. Row keys and next-tool keys come from JSON object keys or from event["next_tool"] or "none", so they are strings for any store the collector writes. cmd_cause already wrapped its values in str(c), so it is unchanged. The PR body names the one difference: a hand-edited store with a non-string next_tool used to crash with an AttributeError and now renders str(value).
  • per_session guard removed (friction.py:288): this is safe. counts gets entries only inside the for record in records loop, so the list of rows is empty whenever records is empty, and the division can't run with len(records) == 0.
  • parse_rules flattening: the early continue and the single strip() give the same rule dicts as the nested version.
  • cause_hint merge: cause in ("classifier", "hook") followed by return cause returns the same strings in the same order as the two separate branches. A tuple membership test compares with ==, so an unhashable cause can't raise.
  • Name collisions: _cell is defined once and doesn't shadow anything else in the plugin.

Closing issue #14746, acceptance criteria

  • Behavior unchanged: met for every store the collector writes, based on reading the code; the edge case above is disclosed. CLI flags and exported names are untouched.
  • Diff limited to the listed file plus a fragment: met.
  • Size within 400 lines / 15 files: met (about 30 changed lines in one file).
  • Fragment: met. .changes/session-flow/...d0c9848d.md has bump: patch, ### Changed and the required line, in ASCII.
  • ci-status green: not checked by this lane. The author says pytest and lint were not run in their lane and left them to CI. That claim is unverified here.

No plugin manifest changed, so no manifest lines apply. No .claude/rules/ path rule applied. The PR context contains no embedded instructions.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@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 250da58 Nov 10, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14746-42704524105-1 branch November 10, 2026 01:08
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 friction.py session-flow plugin code

0 participants