Skip to content

Share the observability SQL path quoting, store default and die through one sourced file #15620

Description

@kyle-sexton

Agent Brief

Type: Task
Summary: Move the sql_path helper, the OTEL store default line and the die function that three observability scripts repeat into one sourced file, plugins/harness-ops/skills/observability/otel/otel-sql.sh (part of restructuring pass #14622).

Current behavior:
Three scripts under plugins/harness-ops/skills/observability/scripts/ define the same 5-line sql_path, which turns an MSYS path into a Windows one for native duckdb and doubles single quotes for a SQL literal:

  • hook-latency.sh:111-115
  • item-rollup.sh:71-75
  • session-compare.sh:46-50

All three set store with the same one-line default (CC_OTEL_STORE, else a directory under the repository root or the working directory): hook-latency.sh:118, item-rollup.sh:77 and session-compare.sh:52. Each already sets OTEL_DIR="$SCRIPT_DIR/../otel" (hook-latency.sh:29, item-rollup.sh:22, session-compare.sh:21).

All three also define the same 4-line die, which prints <script-name>: <message> to stderr and exits 2, differing only in the printed script name: hook-latency.sh:32-35, item-rollup.sh:25-28, session-compare.sh:24-27. Each defines it after its OTEL_DIR line and before any call.

Desired behavior:

  • New otel/otel-sql.sh, mode 100644, sourced only, headed # shellcheck shell=bash and a "Sourced (not executed) by hook-latency.sh, item-rollup.sh and session-compare.sh" comment, as plugins/harness-ops/skills/plugins/scripts/jq-capture.sh:1-6 is.
  • It holds sql_path, verbatim, and otel_store_to <var>, which assigns the store default line's value into the named variable, in the <name>_to <var> form of jq-capture.sh:8-12. A store="$(...)" form would strip a trailing newline from CC_OTEL_STORE, which the inline line keeps.
  • It also holds die, which runs printf '%s: %s\n' "$OTEL_PROG" "$1" >&2 and exits 2, so the script name is a parameter rather than a literal and each message stays byte-identical.
  • Each script sets OTEL_PROG to its own name (hook-latency, item-rollup, session-compare) and sources the file after its OTEL_DIR line with a # shellcheck source=../otel/otel-sql.sh line and source "$OTEL_DIR/otel-sql.sh", both before the first die call. It deletes its own sql_path and die, and replaces its store line with otel_store_to store at the same place, so the order of the duckdb and store checks is unchanged.
  • Each script keeps its own usage, which reads BASH_SOURCE[0] and its own line range (hook-latency.sh:31, item-rollup.sh:24, session-compare.sh:23), its own store and duckdb checks (hook-latency.sh:117,119, item-rollup.sh:78-81, session-compare.sh:53-56) and its own success test (hook-latency.sh:126, item-rollup.sh:95, session-compare.sh:72).
  • No otel-sql.test.sh is added: the test selector maps the new file through each script whose source line names it (scripts/affected-tests.sh:93-97), the three suites run the scripts in place (hook-latency.test.sh:9, item-rollup.test.sh:9, session-compare.test.sh:9), and otel/prune-compact.sh and otel/prune-collector-lifecycle.sh beside it have no suite of their own (git ls-files).

Files:

  • plugins/harness-ops/skills/observability/otel/otel-sql.sh (new)
  • plugins/harness-ops/skills/observability/scripts/hook-latency.sh
  • plugins/harness-ops/skills/observability/scripts/item-rollup.sh
  • plugins/harness-ops/skills/observability/scripts/session-compare.sh
  • a new patch fragment in .changes/harness-ops/: ### Changed, "Internal restructuring, no behavior change."

Key interfaces:

  • Each script's arguments, output, exit codes and error text: unchanged; every die message keeps its script-name prefix byte for byte.
  • otel/prune-compact.sh:86-94 keeps its own sql_path, which adds an OS_KIND gate; otel/cc-otel.test.sh:28-30 keeps its test-local one; hook-transcript-timing.sh keeps its own usage and die (:28-32) and is not touched: it sets no OTEL_DIR and reads transcripts, not the store.
  • No test or eval names sql_path, otel_store_to or OTEL_PROG in the three suites, and no other file carries a copy of the three scripts (scripts/shared-copies.txt, scripts/cross-plugin-source-registry.txt: 0 hits).

Acceptance criteria:

  • sql_path, the store default line and die exist once, in otel/otel-sql.sh, and the three scripts source it.
  • Behavior is unchanged: the same outputs, exit codes and printed results for the same inputs.
  • The diff edits only the listed files and the lines of a test that assert on them when the change breaks that assertion.
  • The pull request stays within 400 changed lines and 15 hand-edited files.
  • hook-latency.test.sh, item-rollup.test.sh and session-compare.test.sh in plugins/harness-ops/skills/observability/scripts/ pass.
  • ci-status is green.

Out of scope:

  • Each script's usage, store and duckdb checks and success test, prune-compact.sh, hook-transcript-timing.sh, a new test file, other duplication, eval cases, fixtures, and skill and agent text.

Activity

  1. added
    status: ready
    on Nov 12, 2026
  2. added theissue type on Nov 12, 2026
  3. removed
    status: ready
    on Nov 12, 2026
  4. melodic-automation-lanes commented on Nov 12, 2026

    @melodic-automation-lanes
    Contributor

    {"v":1,"actor_id":337595936,"title_sha256":"40e83316f9bc98a15ae24ff7235ddd2ba1f8059a9dbaeb58fba345903565f49e","body_sha256":"ef8eb502effa7d08d83a310e5a8d437491197ab08bf534b8ade34dde92457d77"}

  5. github-actions commented on Nov 12, 2026

    @github-actions
    Contributor
    No description provided.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Work status

    needs-triage

    Priority

    low

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions