Skip to content

feat(herdr): add herdr reporter extension for lifecycle state and ses… - #1111

Open
ZoltanOnody wants to merge 1 commit into
getkimchi:masterfrom
ZoltanOnody:herdr-integration
Open

feat(herdr): add herdr reporter extension for lifecycle state and ses…#1111
ZoltanOnody wants to merge 1 commit into
getkimchi:masterfrom
ZoltanOnody:herdr-integration

Conversation

@ZoltanOnody

Copy link
Copy Markdown

…sion identity

Add a kimchi-side herdr integration that reports lifecycle state (idle/working/blocked), blocked prompts, and session identity to herdr when running inside a herdr-managed pane.

  • src/extensions/herdr-reporter.ts: JSON-RPC socket client, single-writer async queue, lifecycle state machine, session reference reporting, and HERDR_ENV gating
  • src/cli.ts: register herdrReporterExtension in extensionFactories
  • src/extensions/herdr-reporter.test.ts: tests for env gating, state transitions, blocked refcounting, queue ordering, session reporting, socket error resilience, and beforeExit listener cleanup
  • docs/herdr.md: document running kimchi inside herdr and resuming with --session

Linked issue

Closes #

What does this PR do?

Checklist

  • I have read CONTRIBUTING.md and agree to the CLA
  • This PR links to an open issue above
  • Tests pass locally (pnpm run test)
  • Lint passes (pnpm run check)
  • Documentation updated if behavior changed

…sion identity

Add a kimchi-side herdr integration that reports lifecycle state
(idle/working/blocked), blocked prompts, and session identity to herdr
when running inside a herdr-managed pane.

- src/extensions/herdr-reporter.ts: JSON-RPC socket client, single-writer
  async queue, lifecycle state machine, session reference reporting,
  and HERDR_ENV gating
- src/cli.ts: register herdrReporterExtension in extensionFactories
- src/extensions/herdr-reporter.test.ts: tests for env gating, state
  transitions, blocked refcounting, queue ordering, session reporting,
  socket error resilience, and beforeExit listener cleanup
- docs/herdr.md: document running kimchi inside herdr and resuming with --session
@kimchi-review

kimchi-review Bot commented Aug 29, 2026

Copy link
Copy Markdown

Kimchi Code Review

Property Value
Commit 5cad158
Author @ZoltanOnody
Files changed 0
Review status Completed
Comments 1 (1 warning)
Duration 131s

Summary

📊 Review Score: 88/100 (overall code quality — 0 lowest, 100 highest)
⏱️ Estimated effort to review: 3/5 (1 = trivial, 5 = very complex)

🧪 Tests: yes — A comprehensive new test file src/extensions/herdr-reporter.test.ts covers environment parsing, reporter sequencing/queueing/draining, socket error handling, extension lifecycle, state-machine transitions, blocked refcounting, shutdown behavior, and a regression test for the module-level beforeExit listener registry. Tests mock node:net hermetically.

📝 Found 1 issue(s). See inline comments for details.

What to expect

Kimchi will analyze the changes in this pull request and post:

  • A summary of the overall changes
  • Inline comments on specific lines with findings categorized by issue type

The review typically completes within a few minutes. This comment will be updated once the review is ready.

Interact with Kimchi
  • @getkimchi review — re-trigger a full review on the latest commit
  • @getkimchi summary — regenerate the PR summary
  • @getkimchi ignore — skip this PR (no review will be posted)
  • Reply to any inline comment to ask follow-up questions or request clarification
Configuration

Reviews are configured by your organization admin.
Review instructions, excluded directories, and severity thresholds can be adjusted per repository in the Kimchi dashboard.


Powered by Kimchi — AI-powered code review by CAST AI

@readme-ai-writer

readme-ai-writer Bot commented Aug 29, 2026

Copy link
Copy Markdown

Documentation Changes Added

Page Section Action Summary
coding-herdrGuides🆕 CreatedCreate documentation page for the herdr reporter extension that reports Kimchi's lifecycle state and session identity to herdr.

🔗 View all changes in ReadMe


Actions

  • Merge documentation branch with PR merge
  • Delete documentation branch with PR close

If neither actions are selected, on PR close/merge the docs branch in ReadMe will remain open.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 Thanks for your first PR on kimchi! A maintainer will review it soon.
Please make sure your PR links to an open issue and your checklist is complete.

@kimchi-review kimchi-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Review Score: 88/100 (overall code quality — 0 lowest, 100 highest)
⏱️ Estimated effort to review: 3/5 (1 = trivial, 5 = very complex)

🧪 Tests: yes — A comprehensive new test file src/extensions/herdr-reporter.test.ts covers environment parsing, reporter sequencing/queueing/draining, socket error handling, extension lifecycle, state-machine transitions, blocked refcounting, shutdown behavior, and a regression test for the module-level beforeExit listener registry. Tests mock node:net hermetically.

📝 Found 1 issue(s). See inline comments for details.

publishState(true)
released = true
// De-register from the process-level backstop so repeated
// extension instances (e.g. test reloads) do not accumulate

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️🔧 Maintainability

The subscription created by pi.events.on("herdr:blocked", ...) is not captured or unsubscribed when the extension is released. In a long-running process or multi-session host that creates and releases several reporter instances, the shared event bus retains stale listeners that do nothing but check if (!rootSession) return, leaking memory and CPU cycles and potentially tripping the bus's own max-listeners warning.

💡 Suggestion: Store the unsubscribe function returned by pi.events.on("herdr:blocked", ...) and call it inside releaseReporter before removing the instance from beforeExitReleasers, e.g., const unsubscribeBlocked = pi.events.on("herdr:blocked", ...); ... unsubscribeBlocked().

@aweris

aweris commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Hey thanks for contribution. I didn't understand from PR, what is the purpose of this PR and did you see https://github.com/getkimchi/herdr-kimchi ?

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.

2 participants