Skip to content

refactor: engine/ module — wire to Derivation ontology, delete primitive-string fields #161

Description

@i-am-logger

Tracks: core-cleanup audit 2026-04-18

Problem

pr4xis/src/engine/ contains a parallel primitive-typed runtime system that duplicates the formal/logic/derivation ontology and leaks Rust primitives across its public API.

Specific violations

engine/trace.rs:

pub struct TraceEntry {
    pub step: usize,
    pub situation_before: String,  // primitive
    pub action: String,             // primitive
    pub precondition_results: Vec<PreconditionResult>,
    pub situation_after: Option<String>,  // primitive
    pub success: bool,              // primitive bool
}
pub struct Trace { entries: Vec<TraceEntry> }

Trace + TraceEntry duplicate DerivationConcept::Derivation + DerivationConcept::DerivationStep (JSV 1996; Plotkin 1981; Lambek 1968).

engine/precondition.rs:

pub enum PreconditionResult {
    Satisfied { rule: String, reason: String },
    Violated  { rule: String, reason: String, situation: String, attempted_action: String },
}

Every field is String. Satisfied maps to DerivationConcept::Witness (Martin-Löf 1984); Violated maps to ProofTheoryConcept::Counterexample. Both should be typed ontological entities.

engine/situation.rs:

pub trait Situation { fn describe(&self) -> String; ... }

describe() -> String is a primitive-leak. Situations ARE Hypothesis (pre-state) / Consequence (post-state) in Derivation.

engine/engine.rs:

pub enum EngineError<A: Action> {
    LogicalError { reason: String },  // primitive string
    ...
}

Why this is an ontological issue

Violates feedback_api_ontological_from_day_one. Was surfaced in the prior-session summary as "Unify pr4xis::engine::Trace + PipelineTrace into one Derivation type".

Proposed direction

  1. Move / wire engine types through the formal/logic/derivation ontology (or whichever core logic home Derivation ends up in).
  2. Trace → uses DerivationConcept::Derivation (or is one).
  3. TraceEntryDerivationStep carrying typed Witness / Hypothesis / Consequence.
  4. PreconditionResult::SatisfiedWitness; ViolatedCounterexample.
  5. Situation trait → returns typed representation (DOLCE Being or ontology-specific), not String.
  6. EngineError::LogicalError → typed ontological entity.

Depends on

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions