Skip to main content

Module ai

Module ai 

Source
Expand description

The AI boundary: a fixed vocabulary of primitives that the Phase 2 intelligence layer is allowed to emit.

Shipped in 0.4.0 as definitions + validation. There is no runtime executor — nothing in this module touches the filesystem or runs migrations. What it does do:

  1. Define the complete set of operations the AI layer can propose (Primitive).
  2. Enforce strict serde shape: unknown ops, unknown keys, and missing fields all fail to parse (deny_unknown_fields everywhere).
  3. Provide structural validation (validate_primitive) and plan-level simulation (Plan::validate) so a proposed change set is checked end-to-end before any hypothetical executor sees it.

Core rule enforced at the boundary (0.5.0): if a change cannot be expressed as one of these primitives, it is rejected — no free-form code generation, no partial writes, no “close enough” fallback. A project whose shape cannot be described in this vocabulary is a project the AI layer will refuse to touch.

Re-exports§

pub use executor::execute_plan_document;
pub use executor::plan_execution;
pub use executor::plan_retrofit_foreign_keys;
pub use executor::render_preview_human;
pub use executor::ExecuteOptions;
pub use executor::ExecutionError;
pub use executor::ExecutionPreview;
pub use executor::ExecutionResult;
pub use executor::FileChangeKind;
pub use executor::ParsedModelsFile;
pub use executor::PlannedFileChange;
pub use executor::ProjectView;
pub use executor::RetrofitReport;
pub use industry::industry_schema_for;
pub use industry::IndustrySchema;
pub use intake::sketch;
pub use intake::FieldSketch;
pub use intake::ModelSketch;
pub use intake::ProjectSketch;
pub use planner::generate_plan;
pub use planner::ContextConfig;
pub use planner::PlanError;
pub use planner::PlanRequest;
pub use planner::PlanResult;
pub use review::build_plan_document;
pub use review::build_plan_document_with_timestamp;
pub use review::classify_risk;
pub use review::compute_impact;
pub use review::load_plan;
pub use review::render_plan_document_json;
pub use review::render_review_human;
pub use review::review_plan;
pub use review::warnings_for;
pub use review::LoadedPlan;
pub use review::PlanDocument;
pub use review::PlanImpact;
pub use review::PlanReview;
pub use review::ReviewError;
pub use review::RiskLevel;
pub use review::ValidationOutcome;
pub use review::PLAN_DOCUMENT_VERSION;
pub use crate::schema::RelationKind;

Modules§

executor
Safe Executor — 0.5.2.
industry
Industry schemas — 0.6.0.
intake
Free-text → typed ProjectSketch — the entry point of the AI-assisted onboarding flow (rustio ai start).
planner
Rule-based AI planner — the brain of the 0.5.0 intelligence layer.
review
Plan Review Layer — 0.5.1.

Structs§

AddField
AddModel
AddRelation
ChangeFieldNullability
Flip a field’s nullability (Option<T>T).
ChangeFieldType
Change a field’s Rust type. The executor is responsible for translating the change into a migration (and refusing lossy conversions); this primitive only records the intent at the schema layer.
CreateMigration
Attach a raw SQL migration alongside a schema-level change.
FieldSpec
A single field on an add_model / add_field primitive.
Plan
A proposed set of primitives to apply in order.
RemoveField
RemoveModel
RemoveRelation
RenameField
Rename a single field of a model (schema-level). Data-preserving.
RenameModel
Rename a model (schema-level). Data-preserving: the AI executor must translate this into a table rename, not a drop+recreate.
UpdateAdmin
Mutate one admin-facing attribute of a field without changing its type — for example flipping searchable on or off.

Enums§

OnDelete
Referential-integrity action triggered when a referenced row is deleted. 0.9.0 introduces this on AddRelation.
Primitive
The complete set of operations the AI layer is allowed to perform on a RustIO project.
PrimitiveError
Reasons a primitive (or a plan composed of primitives) can be rejected. The AI boundary converts these into a blunt refusal — the executor never silently “fixes” a primitive or applies a partial plan.

Functions§

assert_schema_version_supported
Sanity hook for callers that want to assert they’re looking at a schema the current rustio-core understands before doing anything else. Exported for executor code; this module uses it in tests.
validate_against
Semantic check: a primitive is valid against a given schema. Used both standalone and as the per-step check inside Plan::validate.
validate_primitive
Structural check: validates one primitive in isolation, without comparing against a surrounding schema. Catches empty names, bad types, and internally inconsistent payloads.