Skip to content

refactor(harness-ops): simplify session log hooks without behavior change - #15673

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14508-43295213968-1
Nov 12, 2026
Merged

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

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #14508

Summary

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

Simplified three of the nine listed harness-ops files with no behavior change. In session-event-log.sh, field_to and scalar_to now clear their output first and assign on a match, replacing if/else blocks, and the extras loop splits into one loop for ids and one for payload bodies, in the same key order. In session-log-lib.sh, slog_root_to clears its output once and returns early instead of repeating the empty-assign-and-return block four times; this drops a redundant empty-probe check that the containment test already covers. slog_guard_ok also folds its two refusal checks into one. In session-retention.sh, the doomed-file filter is one condition. The other six files were left unchanged. plugin_cache_versions.py is a byte-identical shared copy (scripts/cross-plugin-source-registry.txt) with nothing worth syncing across plugins. python-probe.sh, registrations.py, skill-usage-audit.sh, changelog-releases.sh and fetch-changelog.sh are already minimal, and the remaining candidates (one jq read of the fetch manifest, dirname by parameter expansion) would risk escaping or path-shape differences.

Not verified

  • The plugin test suites (session-event-log.test.sh, session-retention.test.sh, hook-telemetry-sink.test.sh, harness-ops-paths.test.sh) were not run directly; this lane runs only the named wrappers, so they are left to the PR's CI beyond what check-affected selected
  • ai-slop deterministic detector (detect.sh) was not run on the changelog fragment because this lane's Bash runs only the named wrappers; the rubric read by hand found no tells, and no findings file was written
  • ci-status green is a PR CI check, left to the PR's CI
  • Changes are left uncommitted in the working tree as the runner instructs; the runner turns them into the commit

Fix

  • plugins/harness-ops/hooks/session-event-log.sh: field_to and scalar_to set the empty default then assign on match, replacing if/else; the extras loop splits into id and body loops, in the same order
  • plugins/harness-ops/hooks/session-log-lib.sh: slog_root_to clears its output once and uses early returns, dropping the redundant empty phys_probe test; slog_guard_ok combines its two refusal checks
  • plugins/harness-ops/hooks/session-retention.sh: doomed-file loop body becomes one condition
  • .changes/harness-ops/work-resolve-issue-issue-14508-43295213968-1-0a8c1e60.md: patch fragment, ### Changed, 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against 505a3f2:

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

The run reports:

  • check-changelog-fragments: all 8 fragments valid (run before and after tidy)
  • check-changed-skills: no changed skills, nothing to gate (run before and after tidy)
  • check-affected: 13 passed, 6 skipped over 4 changed files (run before and after tidy)
  • fresh-context review subagent: traced every rewritten construct against the old code; no behavior differences, no caller under set -e, no test asserting on the changed lines; two theoretical caller aliasing cases that no current caller hits
  • tidy-diff: pass 1 removed one redundant guard in slog_root_to; passes 2 and 3 found nothing; passes 4 and 5 left the fragment unchanged
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/43295213968

Left out: the items under Not verified.

Related

#14508

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

Copy link
Copy Markdown
Contributor

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

Code review: PR #15673, a refactor of the harness-ops session log hooks

I found no problems. I read the whole diff for all 4 changed files and checked each rewritten construct against the base code.

Behavior equivalence (what I checked)

  • session-event-log.sh field_to / scalar_to: the variable is cleared first and then assigned on a match, followed by return 0, so the status is still 0. The two versions give the same result.
    • field_to copies its haystack into field__in before the clear, so a shared variable cannot lose its value.
    • None of the scalar_to callers (value, line 225) passes top as <var>, so clearing early cannot wipe the text it searches.
  • The extras loop split into an id loop and a body loop: the key order is the same: prompt_id tool_use_id agent_id, then tool_name file_path reason. Ids are still checked with slog_valid_id and stored as s. Bodies are still stored as b.
  • session-log-lib.sh slog_root_to: each early || return 0 / && return 0 matches one of the old refusal branches.
    • The old [[ -z "$slog__phys_probe" ]] test that was dropped is covered by the containment test. $PWD after a successful cd -P is never empty, so an empty probe can match neither == nor the /-prefix glob, and the function still returns empty.
    • The only caller variable is root, so it cannot collide with the slog__ locals.
  • slog_guard_ok: ((slog__other || slog__comment)) && return 1 is the same as the two old if blocks.
  • session-retention.sh: the single condition -z protected && -n old is the same as the two old continue guards.
  • set -e: none of the three scripts uses it; all use set -uo pipefail. A failed && list in a loop or as a non-final statement therefore cannot stop a script, and set -e would ignore such failures anyway.

Closing issue #14508 acceptance criteria

  • Behavior unchanged: met, from my reading of the code (I could not run anything). The existing suites session-event-log.test.sh, session-retention.test.sh and hook-telemetry-sink.test.sh run these paths and would catch a regression.
  • Only listed files and fragments edited: met.
  • Within 400 lines and 15 files: met, with about 60 changed lines across 3 hand-edited files.
  • Fragment: met. bump: patch, ### Changed, and the required line are all present.
  • ci-status green: not checked by this lane, which has no CI access. The PR's own checks of this are author-claimed and unverified.

Prior findings

This is the lane's first review of this PR (0 earlier heads), so it is not a blocking-only review and nothing was posted before.

@github-actions

Copy link
Copy Markdown
Contributor

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

Security review: PR #15673 (harness-ops session log hooks simplification)

I found no security issues. I read every hunk of all 4 changed files. None of them matches a trusted-path glob, and none touches a trust control, a merge hold, a plugin manifest or a standing instruction.

What I checked

  • slog_root_to (plugins/harness-ops/hooks/session-log-lib.sh), retention root containment. This check matters because session-retention.sh deletes files under the root it returns. The new early-return form refuses the same cases the old one did:
    • The output is cleared once at L188, before any refusal path.
    • The lexical check, the empty-anchor check, the empty-probe check and the failed cd -P all still return empty at L191 and L197.
    • The PR drops the explicit "empty phys_probe" test. It is still covered at L201: phys_probe stays empty when cd -P fails (L199). phys_project is a non-empty $PWD, and an empty string matches neither == phys_project nor phys_project/*, even when the anchor is /.
    • The refusal of a root that resolves to the anchor itself is unchanged (L202).
    • None of these hooks runs under set -e (each uses set -uo pipefail), so the new &&/|| lists cannot change control flow by exiting the shell.
  • slog_guard_ok, the .gitignore guard. ((slog__other || slog__comment)) && return 1 refuses exactly what the two old if blocks refused.
  • session-retention.sh, the doomed-file filter. A file is still deleted only when it is not protected and is old. Protected files remain excluded.
  • session-event-log.sh. field_to and scalar_to behave the same: output cleared, then assigned on a regex match. In the extras loop:
    • prompt_id, tool_use_id and agent_id still pass through slog_valid_id before they are emitted as type s.
    • tool_name, file_path and reason are still emitted as body type b.
    • Key order is unchanged, so no unvalidated value reaches the s path.
  • Changelog fragment. It is prose only.

The PR context file contains no embedded directives. The prior-findings file lists no earlier posts, and blocking only: no, so this was a full review. The PR spends no credits and can cause no charge.

critical-findings: 0

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 505a3f2

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-15673-505a3f24fc53c0298edbbbb1c1af2cdf505619dc, expires on 2026-12-12.

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Merge-Risk: max=MEDIUM demote=false head=505a3f24fc53c0298edbbbb1c1af2cdf505619dc rubric=8.4.12 rater=claude-opus-5-5 checker=claude-opus-5-5

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 12, 2026
Merged via the queue into main with commit db141b2 Nov 12, 2026
62 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14508-43295213968-1 branch November 12, 2026 20:29
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit db141b29817dddaade074f6ebd52308223118977; 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 hooks, lib and scripts harness-ops plugin code

0 participants