Skip to content

fix(plugins): log why a durable session-turn schedule/unschedule silently no-ops - #156

Merged
convyusboy merged 3 commits into
boonfrom
ridho/eng-scheduled-turns-diagnostics
Aug 27, 2026
Merged

convyusboy merged 3 commits into
boonfrom
ridho/eng-scheduled-turns-diagnostics

Conversation

@convyusboy

@convyusboy convyusboy commented Aug 27, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

schedulePluginSessionTurn and unschedulePluginSessionTurnsByTag (src/plugins/host-hook-scheduled-turns.ts) had several early-return gates that silently returned undefined / a success-shaped empty result with zero logging: non-bundled plugin origin, missing sessionKey/message, an unresolvable schedule, the calling plugin record not being loaded in the active registry, and cron.add returning 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 --user unreliable), and cross-referencing the cron_run_logs table 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 a log.warn at each gate, naming the plugin and the specific reason, matching the logging already present on the other failure paths in this same file (unsupported deliveryMode, deleteAfterRun conflict, 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-turns subsystem log instead of only surfacing as an unexplained downstream symptom.

Evidence

  • New test file 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 passed
  • node scripts/run-vitest.mjs src/plugins/contracts/scheduled-turns.contract.test.ts -- 25/25 passed, no regressions

Summary by cubic

Adds warning logs to the silent early-return gates in schedulePluginSessionTurn and unschedulePluginSessionTurnsByTag (src/plugins/host-hook-scheduled-turns.ts) so a durable session-turn no-op now names the plugin and the specific reason instead of returning undefined or 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.ts covering every gate plus a success case asserting no warning is logged.

Written for commit 6efb75c. Summary will update on new commits.

Review in cubic

…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

claude Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@cubic-dev-ai cubic-dev-ai 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.

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.

@gandalfboon gandalfboon 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.

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), same formatScheduleLogContext helper, 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.

@convyusboy
convyusboy merged commit fafc669 into boon Aug 27, 2026
145 checks passed
@convyusboy
convyusboy deleted the ridho/eng-scheduled-turns-diagnostics branch August 27, 2026 09:45
convyusboy added a commit that referenced this pull request Aug 27, 2026
…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
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.

1 participant