crp.sdk¶
Auto-generated reference for the crp.sdk subpackage.
sdk¶
crp.sdk ¶
CRP Progressive SDK - Level 0–3 developer experience (SPEC-032).
Exports
CRPClient - the main steering wheel CRPCompletionResponse, CRPAskResponse - response types CRPResponseMeta - governance summary
CRPClient dataclass ¶
Progressive-disclosure SDK client (SPEC-032).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider | LLMProvider | None | An LLMProvider instance (optional - can set later). | None |
config | CRPConfig | None | A CRPConfig instance (optional - loads defaults or crp.config.yaml). | None |
safety | str | dict[str, Any] | Safety profile name ("balanced", "strict", etc.) or dict. | 'balanced' |
depth | str | Default query depth ("auto", "quick", "standard", "thorough", "exhaustive"). | 'auto' |
app_profile | ApplicationProfile | None | Optional application capability contract used to auto-select provider, relay strategy, and context behaviour. | None |
storage property ¶
Access storage visibility API.
knowledge property ¶
Access knowledge location.
audit property ¶
Access the tamper-evident compliance audit trail.
compliance property ¶
Access EU AI Act / ISO 42001 compliance helpers.
safety property writable ¶
Access the Safety Control Plane (SPEC-033, SPEC-034).
ckf property ¶
Access the Contextual Knowledge Fabric (SPEC-009, SPEC-025).
cso property ¶
Access the Cognitive State Object (SPEC-030).
provenance property ¶
Access the Decision Provenance Engine (SPEC-005).
reasoning property ¶
Access reasoning scaffolds, CQS, and cross-window validation.
activation property ¶
Access CRP activation-mode detection (SPEC-017).
agent property ¶
Access multi-agent safety budget and chain tools (SPEC-012).
events property ¶
Access the protocol event bus (§9).
providers property ¶
Access LLM provider registration (SPEC-008).
extract property ¶
Access the graduated extraction pipeline (§2.5).
gateway property ¶
Access CRP Gateway helpers (SPEC-016).
headers property ¶
Access the CRP HTTP header surface (SPEC-002).
observability property ¶
Access observability subsystems (audit, metrics, telemetry).
policy property ¶
Access the safety policy engine (SPEC-006).
scan property ¶
Access CRP Scan helpers (SPEC-013, SPEC-036, SPEC-039).
comply property ¶
Access CRP Comply helpers (SPEC-040, SPEC-042, SPEC-047, SPEC-048).
orchestrator property ¶
Access the live CRPOrchestrator instance directly.
This exposes every public orchestrator method and subsystem (e.g. client.orchestrator.dispatch(...), client.orchestrator.ckf).
modules property ¶
Access any public class or function in the crp package.
This dynamic mirror lets you reach the full CRP API without importing modules manually::
client.modules.envelope.cdr.cdr_rank(...)
client.modules.security.consent.ConsentManager(...)
core property ¶
Access core orchestrator, session, DAG, ledger, and facilitator.
continuation property ¶
Access continuation manager and helpers.
envelope property ¶
Access envelope builder, packer, reranker, CDR, and formatter.
state property ¶
Access warm store, cold storage, snapshots, event log, and router.
security property ¶
Access safety manifest, consent, RBAC, checkpoints, and audit trail.
resources property ¶
Access adaptive allocator, cost model, overhead, and resource manager.
advanced property ¶
Access curator, feedback, meta-learning, source grounding, and validator.
cli property ¶
Access CLI sidecar handler and startup result types.
errors property ¶
Access public CRP exception classes.
configure(**kwargs) ¶
Apply runtime configuration overrides (Layer 5).
Unknown keys are stored in the unified config. Keys that map to core orchestrator settings are also forwarded when possible.
complete(prompt, system='You are a helpful assistant.', **kwargs) ¶
Single-turn completion with automatic governance (Level 0).
Returns:
| Type | Description |
|---|---|
CRPCompletionResponse | CRPCompletionResponse with |
stream(prompt, system='You are a helpful assistant.', *, depth=None, **kwargs) ¶
Stream a single-turn completion as StreamEvent objects.
Each event has ``event_type`` (``token``, ``extraction``,
``continuation``, ``window_complete``, ``done``, ``error``) and
``data``. Concatenating all ``token`` data values produces the same
text as :meth:`complete`.
Args:
depth: Override depth (``quick`` / ``standard`` / ``thorough`` /
``exhaustive``).
Example::
for event in client.stream("Explain CRP."):
if event.event_type == "token":
print(event.data, end="")
elif event.event_type == "done":
print("
Done")
ingest(path) ¶
Ingest documents into the Contextual Knowledge Fabric.
Accepts a file path, directory path, or list of paths.
ask(question, system='You are a helpful assistant.', depth=None, **kwargs) ¶
Multi-turn quality-aware query with source attribution (Level 1–2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth | str | None | Override depth for this query ("quick", "standard", "thorough", "exhaustive"). Level 2 control. | None |
Returns:
| Type | Description |
|---|---|
CRPAskResponse | CRPAskResponse with quality tier, sources, completeness, and |
CRPAskResponse | inspectable reasoning (Level 2). |
tool(fn) ¶
Decorator: register a tool for tool-mediated dispatch (Level 2).
Usage::
@client.tool
def get_metrics(service: str) -> dict:
return {"cpu": 0.5}
call_tool(name, *args, **kwargs) ¶
Call a registered tool by name (Level 2).
dispatch_positioned(user_request, *, fabric=None, executor=None, profile=None, governor=None, clarify_handler=None, policy=None, oversight_required=None, context_facts=None, max_operations=12, temperature=0.2, max_tokens=1024, prior_cso=None, max_continuation_windows=1) ¶
Run the positioned-tool-loop (CRP-SPEC-049/050) with this client's provider.
Positioning, not injection: each operation positions the model on only the 1–3 tools the protocol selected for it - never the full catalogue. Any @client.tool functions are auto-registered as capabilities when no explicit fabric is supplied.
For multi-turn workflows, pass the previous result's .cso as prior_cso so the follow-up turn is positioned with everything the prior turn established (facts, tool observations, decisions).
Returns a PositionedResult exposing .text, .cso, .event_stream, .observation_count, .headers, and .halted.
conversation(**defaults) ¶
Start a multi-turn positioned conversation that manages state for you.
Each .say(request) runs the positioned loop with the running CSO relayed forward automatically - no manual prior_cso threading::
convo = client.conversation()
r1 = convo.say("Look up the service on port 443.")
r2 = convo.say("Based on that, is it safe for a login page?")
defaults are passed to every dispatch_positioned call (e.g. profile=, max_continuation_windows=, clarify_handler=).
derive_profile(messages, tools=None) ¶
Derive an application capability contract from observed messages.
session() ¶
Return a live view of the current CRP session.
save_config(path) ¶
Save the current unified config to path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Path | Destination file path. | required |
config_hash() ¶
Return a deterministic hash of the loaded unified config.
Returns:
| Type | Description |
|---|---|
str | Hex digest string, or empty string if hashing is unavailable. |
reset() ¶
Clear accumulated session facts (warm store + CKF).
close() ¶
Release orchestrator resources.
CRPAskResponse dataclass ¶
Level 1+2 response - quality-aware with inspectable reasoning (SPEC-032 §3–4).
CRPCompletionResponse dataclass ¶
Level 0 response - drop-in governance (SPEC-032 §2).
CRPResponseMeta dataclass ¶
The one governance object - five fields, not 58 headers (SPEC-032 §2.3).
SourceAttribution dataclass ¶
One source document cited in the response.
sdk.client¶
crp.sdk.client ¶
Progressive SDK - the steering wheel for the CRP engine (SPEC-032).
Level 0: drop-in governance::
import crp
client = crp.SDKClient()
r = client.complete("Summarise the EU AI Act")
print(r.crp.risk) # LOW | MEDIUM | HIGH | CRITICAL
Level 1: quality::
client.ingest("./docs/")
a = client.ask("Write a complete deployment guide")
print(a.quality) # S | A | B | C | D
print(a.sources) # [{title, doc_id, used_facts}]
Level 2: control::
@client.tool
def get_metrics(service: str) -> dict:
return {"cpu": 0.5}
r = client.ask("How is the api service doing?", depth="thorough")
print(r.crp.safety_budget_remaining)
CRPClient dataclass ¶
Progressive-disclosure SDK client (SPEC-032).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider | LLMProvider | None | An LLMProvider instance (optional - can set later). | None |
config | CRPConfig | None | A CRPConfig instance (optional - loads defaults or crp.config.yaml). | None |
safety | str | dict[str, Any] | Safety profile name ("balanced", "strict", etc.) or dict. | 'balanced' |
depth | str | Default query depth ("auto", "quick", "standard", "thorough", "exhaustive"). | 'auto' |
app_profile | ApplicationProfile | None | Optional application capability contract used to auto-select provider, relay strategy, and context behaviour. | None |
storage property ¶
Access storage visibility API.
knowledge property ¶
Access knowledge location.
audit property ¶
Access the tamper-evident compliance audit trail.
compliance property ¶
Access EU AI Act / ISO 42001 compliance helpers.
safety property writable ¶
Access the Safety Control Plane (SPEC-033, SPEC-034).
ckf property ¶
Access the Contextual Knowledge Fabric (SPEC-009, SPEC-025).
cso property ¶
Access the Cognitive State Object (SPEC-030).
provenance property ¶
Access the Decision Provenance Engine (SPEC-005).
reasoning property ¶
Access reasoning scaffolds, CQS, and cross-window validation.
activation property ¶
Access CRP activation-mode detection (SPEC-017).
agent property ¶
Access multi-agent safety budget and chain tools (SPEC-012).
events property ¶
Access the protocol event bus (§9).
providers property ¶
Access LLM provider registration (SPEC-008).
extract property ¶
Access the graduated extraction pipeline (§2.5).
gateway property ¶
Access CRP Gateway helpers (SPEC-016).
headers property ¶
Access the CRP HTTP header surface (SPEC-002).
observability property ¶
Access observability subsystems (audit, metrics, telemetry).
policy property ¶
Access the safety policy engine (SPEC-006).
scan property ¶
Access CRP Scan helpers (SPEC-013, SPEC-036, SPEC-039).
comply property ¶
Access CRP Comply helpers (SPEC-040, SPEC-042, SPEC-047, SPEC-048).
orchestrator property ¶
Access the live CRPOrchestrator instance directly.
This exposes every public orchestrator method and subsystem (e.g. client.orchestrator.dispatch(...), client.orchestrator.ckf).
modules property ¶
Access any public class or function in the crp package.
This dynamic mirror lets you reach the full CRP API without importing modules manually::
client.modules.envelope.cdr.cdr_rank(...)
client.modules.security.consent.ConsentManager(...)
core property ¶
Access core orchestrator, session, DAG, ledger, and facilitator.
continuation property ¶
Access continuation manager and helpers.
envelope property ¶
Access envelope builder, packer, reranker, CDR, and formatter.
state property ¶
Access warm store, cold storage, snapshots, event log, and router.
security property ¶
Access safety manifest, consent, RBAC, checkpoints, and audit trail.
resources property ¶
Access adaptive allocator, cost model, overhead, and resource manager.
advanced property ¶
Access curator, feedback, meta-learning, source grounding, and validator.
cli property ¶
Access CLI sidecar handler and startup result types.
errors property ¶
Access public CRP exception classes.
configure(**kwargs) ¶
Apply runtime configuration overrides (Layer 5).
Unknown keys are stored in the unified config. Keys that map to core orchestrator settings are also forwarded when possible.
complete(prompt, system='You are a helpful assistant.', **kwargs) ¶
Single-turn completion with automatic governance (Level 0).
Returns:
| Type | Description |
|---|---|
CRPCompletionResponse | CRPCompletionResponse with |
stream(prompt, system='You are a helpful assistant.', *, depth=None, **kwargs) ¶
Stream a single-turn completion as StreamEvent objects.
Each event has ``event_type`` (``token``, ``extraction``,
``continuation``, ``window_complete``, ``done``, ``error``) and
``data``. Concatenating all ``token`` data values produces the same
text as :meth:`complete`.
Args:
depth: Override depth (``quick`` / ``standard`` / ``thorough`` /
``exhaustive``).
Example::
for event in client.stream("Explain CRP."):
if event.event_type == "token":
print(event.data, end="")
elif event.event_type == "done":
print("
Done")
ingest(path) ¶
Ingest documents into the Contextual Knowledge Fabric.
Accepts a file path, directory path, or list of paths.
ask(question, system='You are a helpful assistant.', depth=None, **kwargs) ¶
Multi-turn quality-aware query with source attribution (Level 1–2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth | str | None | Override depth for this query ("quick", "standard", "thorough", "exhaustive"). Level 2 control. | None |
Returns:
| Type | Description |
|---|---|
CRPAskResponse | CRPAskResponse with quality tier, sources, completeness, and |
CRPAskResponse | inspectable reasoning (Level 2). |
tool(fn) ¶
Decorator: register a tool for tool-mediated dispatch (Level 2).
Usage::
@client.tool
def get_metrics(service: str) -> dict:
return {"cpu": 0.5}
call_tool(name, *args, **kwargs) ¶
Call a registered tool by name (Level 2).
dispatch_positioned(user_request, *, fabric=None, executor=None, profile=None, governor=None, clarify_handler=None, policy=None, oversight_required=None, context_facts=None, max_operations=12, temperature=0.2, max_tokens=1024, prior_cso=None, max_continuation_windows=1) ¶
Run the positioned-tool-loop (CRP-SPEC-049/050) with this client's provider.
Positioning, not injection: each operation positions the model on only the 1–3 tools the protocol selected for it - never the full catalogue. Any @client.tool functions are auto-registered as capabilities when no explicit fabric is supplied.
For multi-turn workflows, pass the previous result's .cso as prior_cso so the follow-up turn is positioned with everything the prior turn established (facts, tool observations, decisions).
Returns a PositionedResult exposing .text, .cso, .event_stream, .observation_count, .headers, and .halted.
conversation(**defaults) ¶
Start a multi-turn positioned conversation that manages state for you.
Each .say(request) runs the positioned loop with the running CSO relayed forward automatically - no manual prior_cso threading::
convo = client.conversation()
r1 = convo.say("Look up the service on port 443.")
r2 = convo.say("Based on that, is it safe for a login page?")
defaults are passed to every dispatch_positioned call (e.g. profile=, max_continuation_windows=, clarify_handler=).
derive_profile(messages, tools=None) ¶
Derive an application capability contract from observed messages.
session() ¶
Return a live view of the current CRP session.
save_config(path) ¶
Save the current unified config to path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Path | Destination file path. | required |
config_hash() ¶
Return a deterministic hash of the loaded unified config.
Returns:
| Type | Description |
|---|---|
str | Hex digest string, or empty string if hashing is unavailable. |
reset() ¶
Clear accumulated session facts (warm store + CKF).
close() ¶
Release orchestrator resources.
sdk.dynamic¶
crp.sdk.dynamic ¶
Dynamic SDK accessors for full CRP coverage (SPEC-032 advanced surface).
The curated namespace proxies in :mod:crp.sdk.proxies cover the most common subsystems. This module provides two escape hatches that expose the remaining 1,400+ classes and 700+ functions without hand-writing a proxy for each:
- :attr:
CRPClient.orchestrator- direct access to the live :class:~crp.core.orchestrator.CRPOrchestratorinstance. - :attr:
CRPClient.modules- a dynamic mirror of the entirecrppackage.
These accessors are lazy, read-only, and block private names so the SDK surface remains safe and predictable.
sdk.proxies¶
crp.sdk.proxies ¶
Namespace proxies for the progressive CRP SDK (SPEC-032).
These proxies expose internal CRP subsystems through a stable, discoverable SDK surface. Each proxy receives the orchestrator instance and uses lazy imports to avoid heavy dependencies and circular imports.
sdk.proxies_extra¶
crp.sdk.proxies_extra ¶
Additional curated namespace proxies for product-facing CRP subsystems.
These proxies extend the progressive SDK surface with typed accessors for Gateway, HTTP headers, observability, policy, Scan, and Comply. Each proxy receives the orchestrator instance and uses lazy imports to avoid heavy dependencies and circular imports.
CRPScanGitHubApp ¶
Lazy wrapper around crp.scan.github_app.GithubAppClient.
The underlying client is instantiated only when a method that requires GitHub credentials is called, keeping client.scan.github_app() side-effect-free.
installation_token(installation_id) ¶
Mint a short-lived installation access token.
list_repos(installation_id) ¶
List repositories accessible to the installation.
open_remediation_pr(installation_id, owner, repo, base_branch, file_changes, pr_title, pr_body) ¶
Open a remediation pull request (always to a dedicated branch).
ComplyGatewayClient ¶
Lightweight adapter exposing Comply Gateway integration helpers.
Wraps the functions in crp.comply.gateway_client so the SDK surface returns a stable object rather than requiring manual imports.
sdk.proxies_more¶
crp.sdk.proxies_more ¶
Additional curated namespace proxies for the progressive CRP SDK (SPEC-032).
These proxies expose the remaining top-level CRP subsystems through a stable, discoverable SDK surface. Each proxy receives the orchestrator instance and uses lazy imports to avoid heavy dependencies and circular imports.
sdk.response¶
crp.sdk.response ¶
SDK response types - the .crp governance summary object (SPEC-032 §2.3).
At Level 0 the developer sees a five-field summary, not 58 headers::
response = client.complete("Summarise the EU AI Act")
print(response.crp.risk) # "LOW" | "MEDIUM" | "HIGH" | "CRITICAL"
print(response.crp.grounded) # bool
print(response.crp.fabrications) # int
print(response.crp.chain_valid) # bool
print(response.crp.audit_url) # tamper-evident deep link
At Level 1 quality signals are added::
a = client.ask("Write a complete deployment guide")
print(a.quality) # "S" | "A" | "B" | "C" | "D"
print(a.sources) # [{title, doc_id, used_facts}]
print(a.complete) # bool - covered whole task
CRPResponseMeta dataclass ¶
The one governance object - five fields, not 58 headers (SPEC-032 §2.3).
CRPCompletionResponse dataclass ¶
Level 0 response - drop-in governance (SPEC-032 §2).
SourceAttribution dataclass ¶
One source document cited in the response.
CRPAskResponse dataclass ¶
Level 1+2 response - quality-aware with inspectable reasoning (SPEC-032 §3–4).