Repository navigation
fix(plugins): log why a durable session-turn schedule/unschedule silently no-ops - #156
Conversation
…ntly no-ops schedulePluginSessionTurn and unschedulePluginSessionTurnsByTag had several early-return gates (non-bundled origin, missing sessionKey/message, an unresolvable schedule, the calling plugin record not being loaded in the active registry, cron.add returning no job id) that returned undefined / a success-shaped empty result with zero logging. Found while live-debugging browser-handoff's scheduleSessionTurn-based durable resume reporting "Automatic resume is not available right now" on every single call, with no way to tell which gate was rejecting it and no application log surface on the host to observe it any other way. Every gate now logs a warning naming the plugin and the specific reason, matching the logging already present on the other failure paths in this file.
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Heads up: you’re close to your included review allowance. Set a flex budget so reviews don’t pause.
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
…k, cover missing-message and unresolvable-schedule gates
…gnostics test CI's check-test-types caught a real type error: the test used origin: "external" to represent a non-bundled plugin, but PluginOrigin is "bundled" | "global" | "workspace" | "config" -- "external" isn't a member. Swapped to "global", a legitimate non-bundled origin.
There was a problem hiding this comment.
LGTM — purely additive observability, and it closes a real gap. The six silent early-return gates in schedulePluginSessionTurn and the one in unschedulePluginSessionTurnsByTag were the exact kind of thing that turns a scheduling regression into a support ticket with no traceable evidence, so wiring warnings at each one is the right call.
A few things I checked:
- Wording + formatting match the existing logged gates in the same file (
unsupported deliveryMode,deleteAfterRun requires a one-shot schedule, reserved-delimiter,cron service unavailable) — same subsystem logger (plugins/host-scheduled-turns), sameformatScheduleLogContexthelper, same "plugin session turn scheduling failed (…): reason" shape. No new logger, no drift. - Log strings name the plugin id and the specific reason on every gate — that's what makes them actually useful in the ENG-17466 style investigation.
- Behavior unchanged: every touched gate still returns the same
undefined/{ removed: 0, failed: 0 }as before. - Test coverage is one-per-gate + a success case asserting zero warnings, which is exactly the shape that catches a future refactor accidentally silencing one of them again. Contract tests still green (25/25).
Ship it.
…er identity, as scheduling liveness (#159) * fix(plugins): treat per-registry lifecycle, not global "active" pointer identity, as scheduling liveness isLoadedRecordInActiveRegistry() (gating scheduleSessionTurn, unscheduleSessionTurnsByTag, and sendSessionAttachment) required getActivePluginRegistry() === <the plugin's own captured registry> -- exact object identity against a single, global, process-wide "active registry" pointer. Root-caused via live log evidence from PR #156's new diagnostics ("plugin record is not loaded in the active registry"): a cron-triggered or non-default-agent agent turn can legitimately install its OWN plugin registry as the global "active" pointer on a cache miss in ensureStandaloneRuntimePluginRegistryLoaded (e.g. after config drift, or scoping to a different agentId's workspace). That does NOT mean an already-loaded bundled plugin's own registry was torn down -- it's still referenced by other tracked surfaces (the real channel/http-route pins), so setActivePluginRegistry's own retirement logic (retirePluginRegistryIfUnused) correctly leaves it live. But the identity check above treated "not currently the global active pointer" as equivalent to "retired", so browser-handoff's scheduleSessionTurn-based durable resume (built to fix "agent forgets everything") silently no-op'd on every single call from a cron-triggered turn -- which is exactly how it always runs. Fixes it by aligning with the sibling check shouldCommitWorkflowSideEffect in the same closure, which already correctly uses per-registry lifecycle flags (isPluginRegistryActivated / isPluginRegistryRetired) instead of global pointer identity, and is unaffected by this exact class of bug. Verified safe against the existing "stale-registry protection" test: a genuinely retired registry (no longer referenced by any tracked surface) is still correctly rejected, since retirement tracks actual usage via isRegistryLive, not the active pointer. * Address cubic review: release the channel pin at the end of the new regression test so the registry doesn't stay artificially live for later tests
What Problem This Solves
schedulePluginSessionTurnandunschedulePluginSessionTurnsByTag(src/plugins/host-hook-scheduled-turns.ts) had several early-return gates that silently returnedundefined/ a success-shaped empty result with zero logging: non-bundled plugin origin, missingsessionKey/message, an unresolvable schedule, the calling plugin record not being loaded in the active registry, andcron.addreturning no job id.Why This Change Was Made
Live-debugging browser-handoff's
scheduleSessionTurn-based durable resume tonight (ENG-17466): every single call reported "Automatic resume is not available right now" -- on this specific host there's no application log surface (no gateway log file,journalctl --userunreliable), and cross-referencing thecron_run_logstable showed zero historical evidence the scheduling mechanism has ever fired for this plugin. With no logging at any of the silent gates, there was no way to determine which one was rejecting the call. This adds alog.warnat each gate, naming the plugin and the specific reason, matching the logging already present on the other failure paths in this same file (unsupporteddeliveryMode,deleteAfterRunconflict, reserved tag delimiter, cron service unavailable).User Impact
Purely additive observability -- no behavior change. The next time a bundled plugin's durable session-turn scheduling silently no-ops, the reason will be visible in the
plugins/host-scheduled-turnssubsystem log instead of only surfacing as an unexplained downstream symptom.Evidence
src/plugins/host-hook-scheduled-turns-diagnostics.test.ts: 6 tests, one per gate, asserting the exact warning fires (and that a successful schedule logs nothing).node scripts/run-vitest.mjs src/plugins/host-hook-scheduled-turns-diagnostics.test.ts-- 6/6 passednode scripts/run-vitest.mjs src/plugins/contracts/scheduled-turns.contract.test.ts-- 25/25 passed, no regressionsSummary by cubic
Adds warning logs to the silent early-return gates in
schedulePluginSessionTurnandunschedulePluginSessionTurnsByTag(src/plugins/host-hook-scheduled-turns.ts) so a durable session-turn no-op now names the plugin and the specific reason instead of returningundefinedor a success-shaped empty result with zero signal. Behavior is unchanged; this is purely additive observability, added while investigating ENG-17466 where browser-handoff's durable resume reported "Automatic resume is not available right now" with no log surface to trace the cause.Adds
src/plugins/host-hook-scheduled-turns-diagnostics.test.tscovering every gate plus a success case asserting no warning is logged.Written for commit 6efb75c. Summary will update on new commits.