Skip to main content

kian_plugin/hooks/
mod.rs

1//! `kian-plugin::hooks` — the hook-plugin core (PLUGIN-SPEC v2.2,
2//! ADR-028): the closed hook vocabulary, the §3.2 payload views, the
3//! §5 grant model, the hook-scoped tier-0 registry and the `HookBus`
4//! dispatch core. P3a adds the sidecar tier's runner/ABI/manifest
5//! ([`sidecar`]); the config surface, per-worker resolution and the
6//! set digest are P3b.
7//!
8//! The bus never writes events, never touches projections and never
9//! imports a harness (§10.7 / ADR-028 D4): it is called from control
10//! flow and returns verdicts. Nothing in this module can append an event.
11//!
12//! Module map (K1 — later phases grow `sidecar/`, `resolve.rs`,
13//! `digest.rs` without moving these):
14//! - [`ids`] — the closed §3.1 catalog (`HookId`, `HookMode`,
15//!   `HookClass`), the empty harness registry (§3.6)
16//! - [`views`] — the §3.2 payload structs and the verdict types
17//! - [`grants`] — the closed §5.1 grant set and the reply → required
18//!   grant map (§3.3)
19//! - [`registry`] — hook-scoped tier-0 registration (§5.3) over the
20//!   existing `Disposer`
21//! - [`failure`] — failure classification and the grant-keyed class
22//!   defaults (§11.1); [`failure::resolve_outcome`] is the only place a
23//!   reply becomes a verdict (K6)
24//! - [`bus`] — the `HookBus` façade: §8.3 dispatch order, the §4.1
25//!   admission grid, `admit_post`, the §4.6 settle decisioning, the
26//!   §10.6 audit lines and the K7 veto marker
27//! - [`ports`] — the seven port methods (§4, verbatim) and `SettleCtl`
28//! - [`wire`] — the §3.2/§7.6 bounds and digest helpers the P2 call
29//!   sites build their views with (one `sha2` edge, K10)
30//! - [`sidecar`] — the P3a sidecar tier: §6 manifest, §7 stdio ABI,
31//!   the spawn-hardened runner with §6.4/§6.5 counters and quarantine
32
33pub mod bus;
34pub mod digest;
35pub mod failure;
36pub mod grants;
37pub mod ids;
38pub mod ports;
39pub mod registry;
40pub mod resolve;
41pub mod session;
42pub mod sidecar;
43pub mod views;
44pub mod wire;
45
46pub use bus::{
47    DEFAULT_MAX_SETTLE_VETOS, HookBus, VETO_MARKER_PREFIX, is_veto_marker, veto_marker,
48    veto_marker_prefix,
49};
50pub use digest::{process_sha256, set_digest};
51pub use failure::{Cause, ClassDefault, FailureClass, Outcome, SpeechCode, resolve_outcome};
52pub use grants::{
53    Grant, GrantError, GrantSet, ReplyShape, observe_grant_for_class, reply_required_grant,
54    veto_grant_for_class,
55};
56pub use ids::{
57    HARNESS_REGISTRY, HarnessPoint, HookClass, HookId, HookMode, PayloadKind, catalog,
58    harness_declared,
59};
60pub use ports::{HookPorts, SettleCtl};
61pub use registry::{
62    HandlerId, HookFn, HookPayload, HookReply, Registry, ReplyErrCode, SessionScope,
63    global_registry, register, register_scoped,
64};
65pub use resolve::{
66    EffectivePlugin, InstanceDecl, LimitOverrides, Resolution, ResolveError, ResolveErrorCode,
67    ScopesConfig, SidecarConfig, WorkerScope, resolve, validate, validate_shape,
68};
69pub use session::{SessionSetGuard, SidecarRuntime};
70pub use views::{
71    AdmissionInfo, AdmitDraft, AdmitInput, AdmitPostInput, AdmitReceiptView, AdmitTarget,
72    AdmitVerdict, ChannelProvenance, EXEC_WORKER_KEY, FrameInfo, Origin, PermissionView,
73    RecoveryView, RedactionReport, RequestMeta, ResponseView, SettleVerdict, SettleView,
74    ToolCallView, ToolPostView, ToolVerdict, TurnErrorAudit, durable_worker_binding,
75};
76pub use wire::{
77    FRAME_PAYLOAD_MAX_BYTES, PREVIEW_MAX_BYTES, bounded_value, preview, serialized, sha256_hex,
78};