Skip to content

refactor(hooks): run the repo telemetry sink through the harness-ops sink - #15457

Merged
kyle-sexton merged 1 commit into
mainfrom
refactor/telemetry-sink-shim
Nov 11, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
refactor/telemetry-sink-shim

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #15440

Summary

.claude/hooks/hook-telemetry-sink.sh was a 178-line hand-kept copy of plugins/harness-ops/hooks/hook-telemetry-sink.sh, and its test existed partly to catch the two drifting. It is now a short shim that sources the plugin sink, so one copy remains and no extra process starts. Part of restructuring pass #14381.

Built in a session because the issue lane cannot write under .claude/ (patch-protected-path, run 43107852341); agreed with the hub session.

session: Simplify Planning

Fix

  • The shim computes its directory by parameter expansion (no dirname fork) and sources the plugin sink, which resolves its own hook-utils.sh and session-log-lib.sh from its own path. The repository settings still point at the same hook path.
  • The test keeps its end-to-end smoke check and replaces the copy comparison with a pin on the shim's source target.

Verification

  • Before/after on the same envelopes (plain, session-routed, malformed, empty): identical exit codes, stdout/stderr and written files between the old copy at origin/main and the new shim.
  • bash .claude/hooks/hook-telemetry-sink.test.sh: PASS. shellcheck -x on both files: clean.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_01VQb9Q3tnh28AzDYZ8AUjhH

…sink

.claude/hooks/hook-telemetry-sink.sh was a 178-line hand-kept copy of
plugins/harness-ops/hooks/hook-telemetry-sink.sh, with a test that only
caught the two drifting. It now sources the plugin sink in the same
process. The test keeps its end-to-end smoke check and pins the shim's
source target instead of comparing copies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VQb9Q3tnh28AzDYZ8AUjhH
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 11, 2026 23:11
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T23:12:16.584371Z 7d8c1b3 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

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

Security review: PR #15457, no security issues found

I read every hunk of both changed files. Both sit under the trusted path **/.claude/**, so I read their whole change and what they gate.

  • .claude/hooks/hook-telemetry-sink.sh: The 178-line copy is now a shim. It finds its own directory by parameter expansion and sources plugins/harness-ops/hooks/hook-telemetry-sink.sh. Both are fixed paths inside the repository, and no input from the environment or stdin chooses them. At head, the plugin sink (L53-L59) resets HOOK_DIR from its own BASH_SOURCE[0]. It then loads its own hook-utils.sh and session-log-lib.sh, which sit next to it inside the repository. Its parsing and write logic is the same as the code the diff removes: the same jq field mapping, the slog_valid_id check before a session id becomes a filename, the slog_guard_ok root check, and the size-capped append. Its exit calls end the shim's process, which is the same behaviour as the old standalone script.
    • The hook still has no tokens, secrets or network access, and no trust decision depends on it. It writes local telemetry JSONL only. Untrusted input reaches no new place, and no control is widened.
  • .claude/hooks/hook-telemetry-sink.test.sh: Test only. The byte-for-byte comparison with the plugin copy is replaced by a check that the shim's source line points at the plugin sink. The end-to-end smoke check stays. No security surface.

Instruction surface: The diff removes comments that describe how the sink behaves, but no rule. That behaviour still runs in the plugin sink it sources, so no guardrail is lost.

Trust controls: None of the controls listed for this lane are touched: the trusted-actor check, the lane token request and broker, the kill switch, and the merge holds. The diff has no plugin manifest changes.

PR context: The description says the change was built in a session because the issue lane cannot write under .claude/ (the patch-protected-path rule). That is a description of where the work was done, not an instruction to this lane, and this pull request does not change that protection.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: PR #15457, the repo telemetry sink as a shim over the harness-ops sink

No findings. I read every hunk of both changed files (.claude/hooks/hook-telemetry-sink.sh and .claude/hooks/hook-telemetry-sink.test.sh), the plugin sink the shim sources, and the PR context. This was a full review, not blocking only: this lane had no earlier review of the PR.

What I checked

  • The shim works when sourced. The shim (.claude/hooks/hook-telemetry-sink.sh#L5-L8) sources the plugin sink. Inside a sourced file, BASH_SOURCE[0] is that file's own path. So the plugin sink resolves its own HOOK_DIR and loads hook-utils.sh and session-log-lib.sh from beside itself (plugins/harness-ops/hooks/hook-telemetry-sink.sh#L53-L59). set -uo pipefail, reading stdin, and the exit 0 paths all run the same as in the old copy, because the shim runs at top level.
  • The only change in behavior is which hook-utils.sh loads. The old copy loaded lib/hook-utils.sh; the shim now loads plugins/harness-ops/hooks/hook-utils.sh. That file is a registered sync copy of lib/hook-utils.sh (scripts/shared-copies.txt#L454), so the records written and the exit codes should stay the same.
  • The hook's path and how settings call it are unchanged. .claude/settings.json still points HOOK_TELEMETRY_SINK at .claude/hooks/hook-telemetry-sink.sh, and the file mode stays 100755. Relative calls still resolve, because the HOOK_DIR-relative path behaves as it did before.
  • The test still pins the shim's source target and keeps its end-to-end smoke check (an envelope must append to hook-events.jsonl). Only the copy-matching assertions are gone, and the trap now cleans up only the smoke directory.

Acceptance criteria from #15440

  • The sink's logic exists once and the repo hook reaches it by source: met. The test checks this by pinning the source line.
  • Behavior unchanged: met. It rests on the registered sync of hook-utils.sh; the smoke test covers the wiring, and the plugin sink's logic has its own test, plugins/harness-ops/hooks/hook-telemetry-sink.test.sh. The author's before/after comparison across the four envelope types is author-claimed; I did not run it.
  • The smoke check still runs; only the copy-matching assertions were removed: met, judged from the code. The author says the test passes; I did not run it.
  • The diff edits only the listed files: met (2 files).
  • Within 400 changed lines and 15 files: met.
  • ci-status green: not checked. I have no shell or GitHub access.

No embedded instructions in the PR context, and no plugin manifest changes.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit aeaa4a8 Nov 11, 2026
78 of 79 checks passed
@kyle-sexton
kyle-sexton deleted the refactor/telemetry-sink-shim branch November 11, 2026 23:22
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace the repo telemetry sink copy with a shim over the harness-ops sink

1 participant