Skip to main content

Crate frame_isa

Crate frame_isa 

Source
Expand description

§Frame ISA - SAM Instruction Set Architecture

Zero-dependency crate defining the 6-byte opcode format for SAM AI systems.

§Overview

Frame ISA defines a compact instruction format for AI output:

[ACT:2 bytes][SUBJ:2 bytes][MOD:2 bytes] = 6 bytes total (big-endian)
  • ACT (Action): What operation to perform (GREET, RESPOND, CALCULATE, etc.)
  • SUBJ (Subject): The topic or entity (TIME, USER, WEATHER, RAG reference, etc.)
  • MOD (Modifier): Style flags (voice, tone, warmth, format, urgency, etc.)

§Usage

use frame_isa::{Action, Subject, Modifier, Instruction};

// Create an instruction
let instr = Instruction::new(
    Action::RESPOND,
    Subject::TIME,
    Modifier::default(),
);

// Serialize to bytes
let bytes = instr.to_bytes();
assert_eq!(bytes.len(), 6);

// Parse from bytes
let parsed = Instruction::parse_one(&bytes).unwrap();
assert_eq!(instr, parsed);

// Use the builder
use frame_isa::{InstructionBuilder, Voice, Tone};

let instr = InstructionBuilder::new(Action::GREET)
    .subject(Subject::USER)
    .voice(Voice::Casual)
    .tone(Tone::Positive)
    .build();

§Action Categories

RangeCategoryExamples
0x00xxSystemNOP, HALT, ERROR, STATUS
0x01xxResponseGREET, CONFIRM, DENY, EXPLAIN, RESPOND
0x02xxQueryASK, REQUEST, SEARCH, RETRIEVE
0x03xxKnowledgeDEFINE, DESCRIBE, COMPARE, SUMMARIZE
0x04xxSkillCALCULATE, SET_TIMER, KNOWLEDGE_SEARCH
0x05xxEmotionEMPATHY, CONCERN, ENCOURAGEMENT
0x06xxTemplateTEMPLATE_LOAD, TEMPLATE_FILL
0x07xxChainCHAIN, FORK, MERGE

§Subject Categories

RangeCategoryExamples
0x00xxSystemNULL, SELF, USER, CONTEXT
0x01xxCommonWEATHER, TIME, DATE, SCHEDULE
0x02xxMath/ScienceNUMBER, EQUATION, PHYSICS
0x03xxTechnologyCOMPUTER, SOFTWARE, AI, API
0x04xxKnowledgeDOCUMENTATION, CONCEPT
0x05xxEmotionsFEELINGS, STRESS, ANXIETY
0x06xxTRM RefsReferences to other TRM models
0xE0xxRAG RefsDynamic document lookups

§Modifier Bit Layout

Bit:  15  14  13  12  11  10   9   8   7   6   5   4   3   2   1   0
      [--VOICE--] [--TONE--] [-WARM-] [--FORMAT--] [ACCURACY] [URGENCY]

§Integration with TRM Models

TinyRecursiveModels (TRMs) output predictions that map to these opcodes. The factored prediction approach uses 3 heads:

  • ACT head → Action code
  • SUBJ head → Subject code
  • MOD head → Modifier flags

This allows small models (~148K params) to achieve 99%+ accuracy on opcode prediction tasks.

Re-exports§

pub use action::Action;
pub use instruction::Instruction;
pub use instruction::InstructionBuilder;
pub use instruction::InstructionError;
pub use instruction::INSTRUCTION_SIZE;
pub use modifier::Accuracy;
pub use modifier::Format;
pub use modifier::Modifier;
pub use modifier::Tone;
pub use modifier::Urgency;
pub use modifier::Voice;
pub use modifier::Warmth;
pub use subject::Subject;

Modules§

action
Action codes for the SAM ISA
instruction
Instruction representation for the SAM ISA
modifier
Modifier flags for the SAM ISA
prelude
Convenience prelude for common imports
subject
Subject codes for the SAM ISA

Constants§

ISA_VERSION
Current ISA version