feat(schemas): dynamic schema enrichment lifecycle (#274)#305
Merged
Conversation
Wire AdapterCache into long-running processes so network-backed schema
enrichment (GitHub labels, ADO states, Jira statuses) is baked once per
project and re-used across requests instead of being re-fetched on every
hit. Adapter enrichment failures now warn on stderr and fall through to
the static schema defaults, letting offline / bad-token sessions still
work.
- core: new AdapterCache with TTL, invalidate, refresh, clear
- core: resolve_inline failures warn instead of aborting
- http: AppState carries the shared cache; spec / adapter / schema
handlers route through resolve_adapter_cached
- http: POST /api/projects/{id}/schema/refresh flushes a project's
cache entry and returns the freshly-resolved schema
- mcp: ServerState holds the adapter behind a RwLock so reload_schema
can swap in a freshly-resolved adapter without restart
- mcp: new reload_schema tool
- cli: capabilities accepts --refresh (informational, single-shot)
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.
Closes #274
Summary
Formalises the
resolve_schema()lifecycle so long-running processes don't pay the schema-enrichment network round-trip on every request, and so offline / bad-token sessions degrade gracefully instead of aborting.AdapterCache(TTL-keyed by project root) —get_or_resolve,refresh,invalidate,clear.resolve_inlinefailures insideAdapterRegistry::createare now warnings on stderr; the CLI falls back to the static schema instead of refusing to run.AppStatecarries the sharedArc<AdapterCache>. Spec / adapter / schema handlers route throughresolve_adapter_cached. NewPOST /api/projects/{id}/schema/refreshflushes a project's cache entry and returns the freshly-resolved schema.ServerStateholds the adapter behind aRwLock<Arc<dyn Adapter>>so the newreload_schematool can swap in a freshly-resolved adapter without restarting the server.leanspec capabilities --refresh(informational on the single-shot CLI; surfaces enrichment errors loudly when present).Provider impact
Touches the adapter seam. The
Adaptertrait surface is unchanged; what changed is how callers hold the resolved adapter:Box<dyn Adapter>returned byresolve_adaptereverywhereArc<dyn Adapter>fromresolve_adapter_cached(shared, re-usable); MCP keepsServerState::adapter()returning a snapshotArc<dyn Adapter>; CLI still getsBox<dyn Adapter>(single-shot, no cache benefit).resolve_inlineerrors inAdapterRegistry::createwere fatalwarning: could not enrich <adapter> schema (…). Using static defaults.on stderr and the adapter falls back to its declared defaults.No serialized format / public-API breakage; UI / agents that already call
GET /api/projects/{id}/schemakeep working unchanged.Test plan
cargo test --all-features(all suites green, including newAdapterCacheunit tests, HTTPschema/refreshintegration tests, and MCPreload_schemadispatch test)cargo clippy --all-features --all-targets -- -D warningscargo fmt --checkreload_schematool advertised intools/listand dispatchableleanspec capabilities --refreshon a GitHub-configured project (left for follow-up — requires a real GitHub token; covered by the existingcreate_github_adapter_resolves_labelsmockito test).Delivers
From the Plan in #274:
resolve_schema()lifecycle inAdapterRegistry::from_project()(treat errors as warnings)AdapterRegistryinstance cache for long-running processes (AdapterCachewith TTL, default 5 minutes)POST /api/projects/{id}/schema/refreshreload_schematool--refreshflag oncapabilitiesNote: the spec's example output of
"(14 options)"after enum field lines is not yet rendered by the capabilities command — the resolved options are already shown in the existingenum [open, closed]form, so the missing piece is purely cosmetic and was deferred to keep this PR focused on the lifecycle / caching mechanics.Generated by Claude Code