feat(plugins): backend-engine-source-cache plugin (Phase 5 #50)#285
Merged
charlie83Gs merged 1 commit intomainfrom Apr 21, 2026
Merged
feat(plugins): backend-engine-source-cache plugin (Phase 5 #50)#285charlie83Gs merged 1 commit intomainfrom
charlie83Gs merged 1 commit intomainfrom
Conversation
Ships `plugins/backend-engine-source-cache/` — contributes the `public-graph` `SourceCacheProvider` behind `GraphTypeComposition.source_cache` on the default graph type. `PublicGraphSourceCacheProvider` wraps the existing `PublicGraphBridge` read path already exposed on every `WorkerGraphEngine` bound to a non-default graph (`lookup_public_cache` / `import_from_public`). Registry lookups resolve to an identical cache hit/miss path — zero behaviour change for existing graphs. Per-call engine resolution: `initialize(services)` stashes the `CoreServices` container; each `lookup` / `import_into_target` call resolves a freshly-bound `WorkerGraphEngine` for `target_graph_id` via `services.graph_engine(target_graph_id)`. The engine already carries the right bridge for that graph (or none, in which case both calls no-op per contract). Engine's raw `ImportResult` gets packed into the typed `SourceCacheImportResult` at the boundary so observability dashboards line up with the ABC. Degraded / malformed results (stale snapshot, missing raw_source_id) resolve to `None` + log — matches the ABC's "cache miss is a degraded result, not an error" contract. `ctx.source_graph_id` is advisory in this implementation: the engine binds to the default-graph upstream at construction time (today's `WorkerState.make_worker_engine` hardcodes that binding). Custom compositions that want a different upstream target will need the bridge itself to accept a source id — tracked as a follow-up. Fail-fast on lookup before initialize: silent `None` would mask a wiring bug as a cache-miss indistinguishable from upstream down. Registered in `kt_config.plugin.load_default_plugins`. No worker wiring this PR — mirrors definition / sync plugin-then-wire sequencing. Tests: 12 contract tests pinning plugin identity, `is_enabled` default, contribution id, registry round-trip, `initialize` idempotency, lookup + import delegation, no-bridge no-ops, degraded engine results, and not-initialized fail-fast.
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
4 tasks
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.
Summary
plugins/backend-engine-source-cache/public-graphSourceCacheProvidermatchingGraphTypeComposition.source_cacheon the default graph typePublicGraphBridgeread path exposed onWorkerGraphEngine(lookup_public_cache/import_from_public) — zero behaviour changeWhat changes
PublicGraphSourceCacheProviderimplements theSourceCacheProviderABC. Constructed once per worker;initialize(services)stashes theCoreServicescontainer for idempotent re-init.lookup/import_into_targetresolves a freshly-boundWorkerGraphEnginefortarget_graph_idviaservices.graph_engine(target_graph_id). The engine already carries the right bridge (or none — both calls no-op per contract).ImportResultgets packed into the typedSourceCacheImportResultat the boundary so observability dashboards line up with the ABC.None+ log — matches ABC's "cache miss is a degraded result, not an error" contract.Nonewould mask wiring bug as indistinguishable from upstream down.ctx.source_graph_idadvisory for now — engine binds to default-graph upstream at construction (today'sWorkerState.make_worker_enginehardcodes). Custom compositions that want a different upstream need bridge itself to accept source id — follow-up.kt_config.plugin.load_default_plugins. No worker wiring this PR — mirrors definition / sync plugin-then-wire sequencing.Test plan
uv run --project plugins/backend-engine-source-cache pytest -x -v(12 contract tests green — plugin identity,is_enabled, contribution id, registry round-trip,initializeidempotency, lookup + import delegation, no-bridge no-ops, degraded engine results, not-initialized fail-fast)uv run --project libs/kt-config pytest -x -v(236 green)uv run --frozen ruff format --check ./ruff check .🤖 Generated with Claude Code