Skip to content

🌱 v6: converge kick_observer.go with v5's fan-out observers - #18315

Merged
hivecommons-hive[bot] merged 5 commits into
v6from
converge/v6-kick-observer
Nov 15, 2026
Merged

hivecommons-hive[bot] merged 5 commits into
v6from
converge/v6-kick-observer

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Why

v6 and v5 each changed src/crux/agent/kick_observer.go, so the file conflicted on the top-ups (#18306) and could conflict again on any later v5 change to it.

Change

  • New adapter. crux.AddLegacyKickObserver(rt, fn) is in the new v6-only file src/crux/kick_observer_legacy.go. It registers a callback in the SetKickObserver shape on the fan-out registry and delivers only the events the single slot delivered: kick-delivered, kick-log-archived and kick-dropped, with the same agent, event and detail. Fan-out-only events (kick-queued, kick-completed, kick-failed, output-signal) are filtered out.
    • A runtime without the registry falls back to SetKickObserver with a no-op remover. That is the sidecar client, whose SetKickObserver already replaced rather than chained, so its behaviour is unchanged.
  • Consumers. cmd/hive/mention_runtime.go (mention responder) and pkg/dashboard/api_linear_agent.go (Linear agent) now register through the adapter.
  • Byte-identical to v5. kick_observer.go and kick_observer_test.go now match origin/v5 exactly, including the single-slot SetKickObserver.
    • kickObserverArchiveDetail, KickObserverDetailSource and KickObserverDetailReason moved unchanged to the v6-only kick_observer_source.go.
    • The archive-detail test moved to kick_observer_source_test.go.
    • The four v6-only deferred-startup-mention tests moved to kick_deferred_test.go, next to the v6-only kick_deferred.go.
    • The chaining test is removed, because SetKickObserver no longer chains.

Behaviour

  • Both observers still fire. On the same kick, the mention responder and the Linear agent receive the same events with the same details. The archive detail still carries source=, so the responder still recognises the kicks it summoned.
  • Ordering. Each observer now gets events strictly in emission order on its own goroutine. Before, the single slot started one goroutine per event, so delivered and archived events could race. The two observers no longer run one after the other on the same goroutine. They were already independent of each other: neither reads the other's state.
  • Clearing the single slot. Calling SetKickObserver(nil) (for example from crux serve) can no longer clear the two hive observers.

Tests

  • TestLegacyKickObservers_BothFireOnSameKick. Both observers registered on one Manager each receive delivered, then archived (detail kick source=mention:IC_1), then dropped, in order. Neither receives the queue or output-signal events. Setting and clearing the single slot does not touch them, and removing one observer leaves the other working.
  • TestAddLegacyKickObserver_FallsBackToSingleSlot / _NilSafe. These cover the fallback and the nil cases.
  • gofmt -l is clean on every edited Go file. Nothing was built or tested locally; CI is the gate.

Remaining divergence: the sandbox kick source argument

v6's startSandboxKickLocked(agent, message, source) takes a third argument and v5's takes two. I am leaving this v6-specific and not opening a v5 backport. In v6 the argument feeds AgentProcess.LastKickSource, KickRecord.Source and the archive detail's source=, all of which exist only on v6 (#7483). v5 has neither field and no source-in-archive detail, so on v5 the argument would only rename the prompt-record source. manager_sandbox.go also diverges in other ways (launchGen, the runSandboxKick signature, TaskMCPURL), so a backport would not remove the structural diff there. The three call sites (kick_async.go, kick_queue.go, manager_kick.go) keep a one-line difference each, and they conflict only if v5 edits those exact lines.

πŸ€– Generated with Claude Code

v6's two kick-callback consumers, the mention responder and the Linear
agent, now register with crux.AddLegacyKickObserver on the fan-out
registry (#18303) instead of chaining through SetKickObserver. The
adapter delivers exactly the events the single slot delivered
(kick-delivered, kick-log-archived, kick-dropped) with the same detail,
in order, on each observer's own goroutine. A runtime without the
registry (the sidecar client) falls back to SetKickObserver, as before.

SetKickObserver is single-slot again, so kick_observer.go and its test
are byte-identical to v5. The v6-only archive-source helpers (#7483)
move to kick_observer_source.go, and the v6-only deferred-mention tests
to kick_deferred_test.go. A new test pins that both observers fire on
the same kick with the same events, order and archive detail.

Signed-off-by: Andy Anderson <andy@clubanderson.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 15, 2026
@clubanderson clubanderson added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Changelog: this PR changes code but carries no changelog entry
(no changelog.d/ fragment and no CHANGELOG.md edit).

If it is user-visible β€” a feature, a fix an operator would notice, a
security change, a migration, a deprecation, or anything breaking β€”
please add a fragment file changelog.d/<category>-<pr-or-slug>.md
containing exactly your entry (see changelog.d/README.md; the
category is one of added/changed/deprecated/fixed/security). Please
do not append to CHANGELOG.md's ## Unreleased directly β€” that
shared section is the merge-conflict generator fragments replaced
(#5675). If it is a refactor, a test-only change, or dependency
churn, no entry is needed and you can ignore this.

This is a reminder, not a gate; it never blocks a merge.

@kubestellar-prow kubestellar-prow Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Nov 15, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Generated by changelog-fragment-guard from the PR title (#5675).
Edit the wording freely, or replace this file with the no-changelog
label if the change is not user-visible.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: clubanderson <407614+clubanderson@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot removed the lgtm Indicates that a PR is ready to be merged. label Nov 15, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

New changes are detected. LGTM label has been removed.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Review follow-ups (below review.backlog.min_severity: P2)

Non-blocking findings below the backlog filing line are listed here instead of as issues, one comment per PR, updated in place. Tick them off as they are fixed; set review.backlog.min_severity: P3 to file every finding.

  • P3 low correctness β€” Observer remover discarded; restarted mention poller leaves stale responders registered (src/cmd/hive/mention_runtime.go:96): syncMentionRuntime builds a new Responder each time the poller starts (after stopMentionPoller, mention_runtime.go:~34-38 and ~135-141) and registers it via AddLegacyKickObserver, but the returned re…

@hivecommons-hive

Copy link
Copy Markdown
Contributor

scanner: the docs link check fails and the branch is 3 behind v5. Merge v5 in and re-check; if it still fails, fix the broken relative link or anchor named in the job log. I don't push to human branches.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

β€” hive: agent=scanner backend=claude model=claude-sonnet-5-5 claude=2.1.325

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Convergence looks right for the in-process runtime, with one regression for runtimes that lack the fan-out registry.

Finding (medium): crux/kick_observer_legacy.go:27-30 β€” the fallback replaces instead of chaining. For a runtime that is not a KickObserverRegistry, AddLegacyKickObserver calls rt.SetKickObserver(fn) and returns a no-op remover. Only agent.Manager implements AddKickObserver (crux/agent/kick_observer.go:22). The sidecar client (crux/api/client) exposes just the single slot. Both consumers still register through this function: the mention responder at cmd/hive/mention_runtime.go:96 and the Linear agent at pkg/dashboard/api_linear_agent.go:64. On a client-backed runtime the second registration therefore overwrites the first, and one of the two stops receiving kick-delivered, kick-log-archived and kick-dropped. The chaining this PR deletes (kick_observer.go, formerly in SetKickObserver) prevented that, and its test TestKickObserver_ChainsObservers is removed with it. The new tests (kick_observer_source_test.go) only cover *Manager.

I did not check whether hostedRuntime can actually be the sidecar client in production. If it can, the fallback should chain (keep a small multiplexer in crux). If it cannot, a comment or test that says so would settle it.

Everything else I read is consistent: the source helpers moved verbatim into kick_observer_source.go, and notifyKickObserver still emits Detail to the fan-out, so the archive detail keeps its source.

β€” hive: agent=reviewer-2 backend=claude model=claude-sonnet-5-5 claude=2.1.325

@hivecommons-hive

hivecommons-hive Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Hive status β€” updated in place; edits do not notify. Full history is in the Activity Monitor.

Review findings from reviewer (folded here because this head already carries its hive review):

Looks correct to me overall: kick_observer.go now matches the v5 single-slot design, and AddLegacyKickObserver (src/crux/kick_observer_legacy.go) filters to exactly kick-delivered, kick-log-archived and kick-dropped. notifyKickObserver still feeds kick-dropped to the single slot, so the moved deferred tests stay valid.

One lifecycle gap worth a look:

  • src/cmd/hive/mention_runtime.go:96 (medium): crux.AddLegacyKickObserver(b.agentMgr, responder.HandleAgentEvent) discards the returned remover. stopMentionPoller only cancels the poller context, and syncMentionRuntime builds a fresh responder on every disabledβ†’enabled transition (it returns early only while mentionPollerCancel != nil). After a toggle, the old responder's observer stays registered and a second is added, so HandleAgentEvent fires twice per event. On v5 the single-slot SetKickObserver replaced the previous observer, so this is a difference from the model being converged to. Suggestion: keep the remover on boot and call it in stopMentionPoller. I did not verify whether HandleAgentEvent is idempotent, so the real impact (duplicate replies vs. harmless repeat) is an open question.

Smaller note: fan-out channels drop events with a warning once 256 are queued (kick_observer.go), where the old single slot spawned a goroutine per event and never dropped. Probably fine at this volume.

@clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Failing checks:

  • check-failure

Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path.

Evidence bundle `#183158639019` sha256:790e48e48eaff611cf12c1ab2c4d2433ff600cb733b4f6990c955257f6245bb8 β€” download from the dashboard or `hivectl review evidence #18315`.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

hive/scanner: the only red check is relative links and anchors resolve. A doc link or anchor touched by this PR no longer resolves; the job log names it. I'm not pushing to a human-authored branch.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

β€” hive: agent=scanner backend=claude model=claude-sonnet-5-5 claude=2.1.325

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Mutation testing

Head 863901923.

❌ gremlins did not produce a report for 1 package(s), so no verdict can be derived from this run (see the job log):

  • crux: gremlins exited 1

Verdict: error (#17349).

Signed-off-by: Andy Anderson <andy@clubanderson.com>
@clubanderson clubanderson added the lgtm Indicates that a PR is ready to be merged. label Nov 15, 2026
@kubestellar-prow kubestellar-prow Bot removed the lgtm Indicates that a PR is ready to be merged. label Nov 15, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

New changes are detected. LGTM label has been removed.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Read the adapter (src/crux/kick_observer_legacy.go), the call sites and src/crux/agent/kick_observer.go at this head. The convergence looks correct, and both observers get delivered/archived/dropped with unchanged details. One regression the body does not mention:

Events can now be dropped under load (medium, src/crux/agent/kick_observer.go:92). Each fan-out observer has a 256-slot channel; when it is full emitKickEvent drops the event and only logs a warning. AddLegacyKickObserver filters inside the callback, so queued/output-signal/completed events still occupy the buffer. The old single slot started a goroutine per event and never lost one. If the mention responder's HandleAgentEvent is slow, a kick-dropped or kick-log-archived for a mention could be lost, and the responder would not see that its kick finished. I could not confirm how slow HandleAgentEvent is in practice, so I'm raising this as a risk, not a proven bug. A cheap mitigation would be to filter before enqueue, or to document the drop as accepted.

Otherwise looks correct to me.

β€” hive: agent=reviewer backend=claude model=claude-sonnet-5-5 claude=2.1.325

@hivecommons-hive
hivecommons-hive Bot merged commit 0dfa48b into v6 Nov 15, 2026
80 of 81 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the converge/v6-kick-observer branch November 15, 2026 18:48
@hivecommons-hive

Copy link
Copy Markdown
Contributor

merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at 8639019.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has signed the DCO. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant