// Copyright 2026 AlphaOne LLC
// SPDX-License-Identifier: Apache-2.0
//
// v0.7 Track G — programmable lifecycle hook pipeline.
//
// This module is the substrate for tasks G1-G11 of the
// `attested-cortex` epic. G1 lands the configuration schema
// (`hooks.toml`) and the SIGHUP-driven hot-reload plumbing.
// Subsequent tasks layer on:
//
//   * G2  — full payload structs for the 20 lifecycle events.
//   * G3  — subprocess executor (exec + daemon modes).
//   * G4  — `HookDecision` contract.
//   * G5  — chain ordering with first-deny-wins short-circuit.
//   * G6  — per-event-class deadlines.
//   * G7+ — actual firing at the memory operation points.
//
// G1 deliberately ships *only* the schema + loader + hot-reload
// signal handler. It does not fire hooks, validate command paths
// against a sandbox, or implement the executor. Those land in
// follow-up PRs on this same `feat/v0.7-g-*` track.

pub mod chain;
pub mod config;
pub mod decision;
/// PE-1 (#1734) — mandatory-hook presence enforcement.
pub mod enforce;
pub mod events;
pub mod executor;
// G10 — recall hot-path helper. Wraps `HookChain::fire` with the
// `PreRecallExpand` payload-marshalling so `mcp::handle_recall`
// stays a one-liner at the fire site.
pub mod recall;
pub mod timeouts;
// v0.7.0 QW-1 — `post_reflect` substrate-side hook plug-ins (file-
// backed auto-export, future post-commit notifications). These are
// distinct from the cross-process `HookEvent::PostReflect` family in
// `events.rs` — those serialise across subprocess boundaries; this
// module is in-substrate (`std::thread::spawn` + the rusqlite
// connection on the worker thread).
pub mod post_reflect;

// v0.7.0 WT-1-D — `pre_store` substrate-side hook plug-ins
// (auto-atomisation deferred-enqueue, future pre-commit observers).
// Same in-substrate discipline as `post_reflect` — distinct from the
// cross-process `HookEvent::PreStore` family in `events.rs`.
pub mod pre_store;

// G2 lifted `HookEvent` out of `config.rs` into `events.rs` and
// attached payload structs to every variant. The re-export keeps
// G1's `use crate::hooks::HookEvent` (and the
// `crate::hooks::config::HookEvent` compatibility alias) resolving.
pub use chain::{
    AskUserPrompt, ChainResult, HookChain, fire_on_index_eviction, spawn_eviction_observer,
    spawn_post_event_observer,
};
pub use config::{FailMode, HookConfig, HookMode, HooksConfigError};
pub use events::{EvictionEvent, HookEvent};
// G4 — full HookDecision contract. G3 shipped a local `Allow +
// Deny` prototype inside `executor.rs`; G4 lifts the type into
// `decision.rs` with the four-variant epic spec (Allow / Modify /
// Deny / AskUser) and a strict JSON wire contract. The re-export
// here keeps G3 call sites (`use crate::hooks::HookDecision`,
// `use crate::hooks::executor::HookDecision`) resolving via the
// canonical `crate::hooks::decision::HookDecision` path.
pub use decision::{DecisionParseError, HookDecision, ModifyPayload, is_pre_event};
pub use enforce::{
    HookEnforceMode, effective_fail_mode, enforce_required_event_presence,
    is_eligible_required_event, preflight_report,
};
// G3 — subprocess hook executor. Re-exports keep call sites
// (`use crate::hooks::HookExecutor`) tidy without requiring every
// caller to know the `executor::` submodule path.
pub use executor::{
    DaemonExecutor, ExecExecutor, ExecutorError, ExecutorMetrics, ExecutorRegistry, HookExecutor,
};
// G6 — per-event-class hard timeouts. Re-exports the budget table
// + violation counter so the doctor surface and the chain runner
// can both reach for the canonical type without a deeper import.
pub use timeouts::{
    EventClass, HOT_PATH_CLASS_DEADLINE_MS, INDEX_CLASS_DEADLINE_MS, READ_CLASS_DEADLINE_MS,
    TRANSCRIPT_CLASS_DEADLINE_MS, WRITE_CLASS_DEADLINE_MS, class_deadline,
    class_deadline_for_event, event_class, per_hook_budget_ms, record_timeout_violation,
    timeout_violations_total,
};
// G10 — pre_recall_expand hot-path helper.
pub use recall::{PreRecallOutcome, apply_pre_recall_expand};
