Skip to content

refactor(debugging): simplify analyze-profile query and convert scripts - #14772

Merged
melodic-automation-lanes[bot] merged 2 commits into
mainfrom
work-resolve-issue/issue-14439-42645154182-1
Nov 9, 2026
Merged

melodic-automation-lanes[bot] merged 2 commits into
mainfrom
work-resolve-issue/issue-14439-42645154182-1

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14439

Summary

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

Simplified query_profile.py and trace_to_sqlite.py without changing what they print, write or return. query_profile.py: a connect_read_only helper replaces two copies of the read-only connect plus authorizer; run_sql now raises Refused, so main's single handler prints every error and the duplicate fail() helper is gone; retainers seeds the start node as (None, "") instead of None, which drops two conditional lookups. trace_to_sqlite.py: load_chrome_trace builds the profile key and payload once for Profile and ProfileChunk events; main's two pre-checks raise InputError into the existing handler instead of repeating the print-and-return-2 lines. build-view.mjs and hitl-loop.template.sh were reviewed under the same four /simplify checks and left unchanged: neither had duplicated logic, a needless branch or repeated work to remove. One edge left as is: set_authorizer now runs outside the close-on-error block, which only matters if it fails on a freshly opened connection, and it cannot fail there.

Not verified

  • test_query_profile.py and test_trace_to_sqlite.py not executed: this lane cannot run an interpreter; left to the PR's CI
  • cant-fail-scan wrapper, run with no arguments, timed out after 2 minutes; CI runs it (check-affected lists cant-fail-scan as CI only)
  • tidy: passes 1-4 ran and made no edits; pass 5 (ai-slop fix) could not run its detector because this lane's Bash allows only the named wrappers, so the one-line fragment was read by hand and no tells were found
  • build (none for Python scripts) and lint (no Python linter is runnable in this lane); left to the PR's CI
  • ci-status green is a PR check left to the PR's CI

Fix

  • plugins/debugging/skills/analyze-profile/scripts/query_profile.py: add connect_read_only and use it in open_heap and run_sql; remove fail() and raise Refused from run_sql, handled once in main; seed retainers' start node as (None, "") to drop the None special cases
  • plugins/debugging/skills/analyze-profile/scripts/trace_to_sqlite.py: compute the Profile/ProfileChunk key and payload once in load_chrome_trace; route main's input-not-found and refuse-to-overwrite checks through the existing InputError handler
  • .changes/debugging/work-resolve-issue-issue-14439-42645154182-1-f192333b.md: new patch fragment, ### Changed, 'Internal simplification, no behavior change.'

Verification

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

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

The run reports:

  • check-changelog-fragments: all 2 fragments valid (run before and after tidy and review)
  • check-changed-skills: analyze-profile PASS, 0 errors, 1 warning that predates this change (description length 630 above the 419 warn setting)
  • check-affected: 13 passed, 6 skipped, 0 failed over 3 changed files
  • fresh-context review subagent over the full diff: no behavior differences found in stdout, stderr text, exit codes, written files, flags or module names used by the tests (test_query_profile.py runs the script as a subprocess; test_trace_to_sqlite.py uses only main, MAX_INPUT_BYTES and os.replace)
  • grep for importers of query_profile internals (fail, run_sql): none outside the file
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42645154182

Left out: the items under Not verified.

Related

#14439

Merge-Risk: max=MEDIUM demote=false head=3fe242b6399f7981794df911f8bd4648434529f0 rubric=8.1.6 rater=claude-opus-5-5 checker=claude-opus-5-5

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

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review needs no new review of 3fe242b6399f7981794df911f8bd4648434529f0: no file of this pull request changed since the review of 8550333.

Security review: no security issues found

I read the whole change in all 3 files. None of them is on a trusted path, and the diff changes no trust control, plugin manifest or standing instruction.

  • query_profile.py read-only SQL guard still holds. The new connect_read_only helper (L59-L62) still opens the database with ?mode=ro and sets the read_only authorizer, which allows only SELECT, READ, FUNCTION and RECURSIVE. Both callers, open_heap and run_sql, run their first execute only after the helper returns, so user-supplied SQL still cannot reach the database without the authorizer.
    • The author's noted edge also checks out: set_authorizer now runs outside the close-on-error block. If it ever failed, the connection would leak and the error would go through the sqlite3.Error handler. No query would run unguarded, so it has no security impact.
  • Error handling in run_sql. It now raises Refused instead of calling fail(), and main catches it in one place. Refused exits with code 2 by default (L83), and the stderr prefix is the same as before, so exit codes and messages are unchanged.
  • retainers start node. It is now seeded as (None, ""). This changes no data flow across a trust boundary.
  • trace_to_sqlite.py changes keep the same behaviour.
    • The new continue comes after the events insert and skips only the Profile/ProfileChunk handling, which matches the old flow.
    • The input-not-found and refuse-to-overwrite checks now raise InputError into the existing handler. They still run before convert, so the script still refuses to overwrite an existing output file.
  • Changelog fragment. Prose only.

The PR context has no embedded instructions aimed at this lane. This was the lane's first review of the PR, so it was not limited to blocking findings.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

claude-review needs no new review of 3fe242b6399f7981794df911f8bd4648434529f0: no file of this pull request changed since the review of 8550333.

Code review: PR #14772, refactor(debugging): simplify analyze-profile query and convert scripts

No findings. I read every hunk of all 3 changed files and the head versions of query_profile.py and trace_to_sqlite.py. I compared each change with the base behavior and found no difference in output, exit codes, files written or messages printed.

Behavior-equivalence check (done by reading the code; nothing was run)

  • connect_read_only: the same URI and the same ?mode=ro flag, and the authorizer is set before any statement runs. One small difference: set_authorizer now runs outside open_heap's close-on-error block. The PR body already notes this. It only matters if set_authorizer fails on a fresh connection, so I'm not reporting it.
  • run_sql uses Refused in place of fail(): Refused defaults to code 2, and main prints query_profile: {exc}. That is the same text and exit code fail() produced. If an SQL error happens partway through, the header and rows already printed still come before the stderr line, as on base. run_sql uses a plain ArgumentParser, so its usage errors still exit through SystemExit and the wider try in main does not catch them.
  • Retainers start as (None, ""): the chain stops at the start node and that node's via is "", both as on base. That holds when idx == 0 too.
  • load_chrome_trace: the new continue only skips events that aren't Profile or ProfileChunk, and nothing after it in the loop body applies to those events. The key and payload are built the same way. The base code's reassignment of the data parameter had no effect because events was already bound.
  • trace_to_sqlite.main pre-checks: they now raise InputError into the existing handler, which prints trace_to_sqlite: input not found: … and trace_to_sqlite: refusing to overwrite … with exit 2. That matches base.

Closing issue #14439 acceptance criteria

  • Behavior unchanged: met, from reading the code. Tests exist that could catch a regression: test_query_profile.py checks exit codes, empty stdout and one-line stderr, plus the exact retainers output including via. test_trace_to_sqlite.py checks the refuse and overwrite paths and Chrome trace profiles. The exact stderr wording isn't asserted anywhere, but this PR leaves that text unchanged.
  • Only listed files and fragments edited: met.
  • Within 400 lines and 15 files: met.
  • ci-status green: CI will decide this. I can't see it from this lane.
  • debugging fragment with ### Changed / "Internal simplification, no behavior change.": met (bump: patch).

The tests, lint and CI results in the PR description were claimed by the author; I did not confirm them. This lane ran no interpreter. The PR context contained no embedded instructions aimed at this lane.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 3fe242b

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-14772-3fe242b6399f7981794df911f8bd4648434529f0, expires on 2026-12-09.

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 9, 2026
@melodic-automation-lanes
melodic-automation-lanes Bot removed this pull request from the merge queue due to a manual request Nov 9, 2026
@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit 4ecd769 Nov 9, 2026
59 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14439-42645154182-1 branch November 9, 2026 19:14
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 4ecd7696fd8c7cde4c10e4f20f4e245c02a26947; 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 scripts, analyze-profile and debug debugging plugin code

1 participant