Repository navigation
feat(plugins): PC-2 — a hook bus and the core scheduler - #544
Open
jwvanderstam wants to merge 1 commit into
Open
jwvanderstam wants to merge 1 commit into
jwvanderstam wants to merge 1 commit into
Conversation
The core now announces three events a plugin can react to. A plugin names a hook in PLUGIN_HOOKS and defines a function of that name; the loader subscribes it after setup succeeds and unsubscribes it on unload or reload. - on_document_ingested from DocumentProcessor.ingest_document(), the one path uploads and connectors share (not also in SyncWorker, which would announce a document twice). - on_scheduler_tick from one daemon thread, every SCHEDULER_TICK_SECONDS. - on_tool_invocation from the tool loop for a permitted tool: name and source, never its arguments; emitted through asyncio.to_thread. emit() is synchronous; a subscriber that raises is logged and skipped, and each gets its own copy of the payload. on_route_mount is deferred: plugins load after create_app() has assembled the routers. A hook named without its function is a malformed manifest. The weekly reranker fine-tune is the scheduler's first subscriber and replaces its threading.Timer: it runs on the first tick a week after its last attempt, on a monotonic clock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jwvanderstam
force-pushed
the
feat/pc2-hook-bus
branch
from
November 14, 2026 10:47
4f3c552 to
b5047fd
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



PC-2 of the plugin contract (
.claude/rules/plugins.md, ROADMAP sprint 10). The core announces three events; a plugin names a hook inPLUGIN_HOOKSand defines a function of that name.on_document_ingestedDocumentProcessor.ingest_document()document_id,filename,workspace_id,chunks,replaced,source_idon_scheduler_tickScheduler, everySCHEDULER_TICK_SECONDS(3600)tick,aton_tool_invocationsrc/tools/executor.py, permitted tools onlytool,sourceDecided by the maintainer (2026-11-13)
emit()is synchronous; the tool loop calls it throughasyncio.to_thread.on_route_mountis deferred: plugins load inbootstrap_app(), aftercreate_app()has mounted the routers.threading.Timer(monotonic clock, first tick a week after the last attempt).Departures from the spec, recorded in ROADMAP
SyncWorkeringests through it, so emitting there too would announce one document twice.src/agent/tool_router.py, which dispatches the aggregator's retrieval rather than tool calls. Arguments are left out: they carry the user's question.Behaviour
setup()succeeds, unsubscribes on unload, and leaves one subscription across a reload.on_route_mount, or a hook without its function, now disables that plugin.Verification
ruff,mypy(src.plugins.hooksin the strict list) andlint-importsare clean.tests/unit/test_hook_bus.pyand the rewritten reranker scheduler tests pass, along with the docs, config and import-cycle guard tests.-x): 3078 passed and 1 failed,test_request_and_ooxml_limits.py::...test_the_application_mounts_it_at_max_content_length_exempting_only_upload, withSystemExitfromvalidate_secrets(). It passes when run alone, so it looks order-dependent. This CI run on 3.12 is meant to settle whether it reproduces here.unit-testswill failpip-auditondnspythonuntil fix(deps): dnspython 2.9.2 and opentelemetry-api 1.45.2 — two CVEs #543 is onmain; that failure is not caused by this change.Docs updated: plugins rule,
plugins/README.md(Hooks section), CLAUDE.md, ROADMAP, file-map, CONFIGURATION, CHANGELOG.🤖 Generated with Claude Code