feat(harness): add host capability seams with inert defaults - #83
Draft
senamakel wants to merge 12 commits into
Draft
feat(harness): add host capability seams with inert defaults#83senamakel wants to merge 12 commits into
senamakel wants to merge 12 commits into
Conversation
Add `harness::host`: ten extension traits an embedding application implements, each paired with a no-op or in-memory default so a host can adopt them one at a time. Nothing in the crate calls them yet — this lands the surface, not the wiring. - MemoryProvider / InMemoryMemoryProvider — scored retrieval over a namespaced corpus. Explicitly not ChatHistory: no messages(), no append, no offsets, no transcript replay or compaction. - ContextComposer / PassthroughContextComposer — system prompt (sync, once per run for prompt-cache stability) plus per-turn fragments (async) with typed placement. - SecurityGate / RootContainedSecurityGate — tool advertisement, per-call authorization (three-valued: allow / deny / require approval), lexical path containment, input screening, and redaction. - BudgetGate / UnmeteredBudgetGate — admission leases, pricing, usage ledger, and a graceful per-turn stop verdict. - DefinitionRegistry / InMemoryDefinitionRegistry over a deliberately minimal AgentDefinition; host-specific data rides in opaque `extras`. - ExperienceStore, LearningSink, ProgressSink, ToolOutcomeClassifier, ModelResolver, each with its inert default. A seam is async only where a realistic implementation performs I/O; lookups, lexical checks, pricing tables, and classification stay sync so adopting them does not force callers to become async. tests/host_seam_hygiene.rs scans the module for embedder vocabulary and fails with file, line, and reason. Its SCANNED_DIRS list must grow as runtime code is relocated into the crate. Design notes in docs/modules/harness/host.md. Patch version bump; the change is purely additive.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Draft
12 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
Adds
harness::host— ten host-capability seams with inert default impls, plus the specthat records why they exist and where their boundary sits.
A generic agent runtime needs a way for an embedding application to supply the capabilities
the runtime itself should not own: long-term recall, turn context assembly, security
decisions, budget admission, agent definitions, experience, learning, progress delivery,
tool-outcome classification, and model resolution. The crate already ships 18 harness
extension traits on exactly this pattern (
ChatModel,Tool,ChatHistory,Store,Summarizer, …); this is ten more of the same kind, not a new architecture.Nothing in the crate calls these yet. They land empty on purpose, so a host can adopt them
incrementally without the runtime depending on the outcome. OpenHuman is the first consumer.
Spec:
docs/spec/host-capabilities-spec.md. Module doc:docs/modules/harness/host.md.Scope boundaries worth reviewing
These are the decisions that shape the surface — each is argued in the spec:
BudgetGateis money and admission only. Context-window fitting isSummarizer+RunLimits, not a budget concern.ProgressSinkis delivery, not transport. No receive side. An interactive loop thatreads from a terminal or chat platform stays host surface.
SecurityGate::filter_toolsis advertisement, not enforcement. Per-call authorizationis
authorize_call, which is the only async method on the trait because it is the onesite that genuinely awaits.
AgentDefinitionis deliberately minimal (id,description,system_prompt,model,tools,extras: Value) withDefaultderived. Richer host types map into itvia
extrasrather than the crate freezing fields it cannot generalize.&State, so a host parks a reloadablehandle there and keeps read-at-call-time semantics with zero crate surface — better than a
virtual getter, and it needs no new type.
Open question for reviewers
All ten are generic over
State, matchingChatModel/Tool/Middleware. That may bethe wrong call, and I would like a maintainer's read before hosts adopt them.
Only 7 of the existing 18 extension traits carry
State, and all 7 are execution traits.The 11 that are genuinely capability traits —
ChatHistory,Store,Summarizer,EmbeddingModel,VectorStore,ResponseCache,WorkspaceIsolation, … — are barepub trait X: Send + Synccapturing their dependencies inArcfields, and are the closeranalogue to these ten.
The alternative is: make the eight capability seams non-generic
Arc<dyn Trait>, keepingStateonly onModelResolver(which must returnModelRegistry<State>) andContextComposer(closest to a middleware). Changing this later is a signature break forevery implementor, so it is cheaper to settle now.
API Or Behavior Changes
Additive only. No existing API changed, no behavior changed. Nothing in the crate
calls the new traits.
New public surface under
harness::host, re-exported from the crate root:MemoryProviderInMemoryMemoryProviderContextComposerPassthroughContextComposerSecurityGateRootContainedSecurityGateBudgetGateUnmeteredBudgetGateDefinitionRegistryInMemoryDefinitionRegistryExperienceStoreNoopExperienceStoreLearningSinkNoopLearningSinkProgressSinkNoopProgressSinkToolOutcomeClassifierNoopToolOutcomeClassifierModelResolverStaticModelResolverVersion
2.1.0→2.1.1(patch). Deliberate: the embedding host pins^2.1, and a minorbump would force a host manifest edit this change is scoped to avoid.
Most methods are sync, matching the call sites they are modelled on. Only
SecurityGate::authorize_call,ContextComposer::prepare_turn, and theMemoryProvider/ExperienceStore/LearningSinkI/O methods are async.Tests
cargo fmt --checkcargo clippy --all-targets -- -D warningscargo clippy --all-targets --all-features -- -D warningscargo build --all-targetscargo build --all-targets --all-featurescargo testcargo test --all-featurescargo test --all-features: 1330 lib tests, all integration targets, 45 doctests, 0 failures.37 of those cover the new module's default impls.
Also added
tests/host_seam_hygiene.rs, which scanssrc/harness/host/for embedder-specificvocabulary and fails with file, line, and reason. It runs under the normal test command rather
than as a CI lane someone has to remember, and its
SCANNED_DIRSlist is documented as needingto grow as more code moves into the crate.
Documentation
docs/spec/host-capabilities-spec.md— the catalogue, the rejected alternatives, and thepublishability boundary. Filed in
docs/spec/perdocs/spec/README.md, indexed from itsModule 1 section.
docs/modules/harness/host.md— per-trait scope table, including the three couplingconcerns resolved by scoping rather than by adding an eleventh trait.