Expand description
§smix-recorder-ir
Intermediate representation for recorded iOS-sim sessions: 8-variant
IRAction enum, RecorderError with kebab-case reason codes, and a
sort_by_timestamp merge helper. Stone — pure types + serde, no
recording I/O, no code generation. Pairs with
smix-recorder (cement) which
fills it in and emits Rust / Maestro YAML.
§Quickstart
use smix_recorder_ir::{IRAction, sort_by_timestamp};
use smix_selector::{Pattern, Selector, Modifiers};
let actions = vec![
IRAction::Tap {
selector: Selector::Text { text: Pattern::text("Login"), modifiers: Modifiers::default() },
timestamp_ms: 1716700000.0,
},
IRAction::Fill {
selector: Selector::Id { id: "username".into(), modifiers: Modifiers::default() },
text: "alice".into(),
timestamp_ms: 1716700005.0,
},
];
assert_eq!(actions[0].kind(), "tap");
assert_eq!(actions[1].timestamp_ms(), 1716700005.0);
let json = serde_json::to_string(&actions[0]).unwrap();
assert!(json.contains("\"kind\":\"tap\""));
assert!(json.contains("\"timestampMs\":1716700000"));
let merged = sort_by_timestamp(&actions);
assert_eq!(merged.len(), 2);§IRAction variants
| Variant | Wire kind | Carries |
|---|---|---|
Tap | "tap" | selector |
Fill | "fill" | selector, text |
Clear | "clear" | selector |
PressKey | "pressKey" | key |
Swipe | "swipe" | direction, optional from-selector |
GoBack | "goBack" | — |
WaitFor | "waitFor" | selector |
HideKeyboard | "hideKeyboard" | — |
All variants carry timestamp_ms: f64. Wire shape uses tag = "kind",
camelCase.
§RecorderErrorReason
| Variant | Wire string |
|---|---|
EmptySession | "empty-session" |
MalformedAction | "malformed-action" |
CleanupFailed | "cleanup-failed" |
CleanupEmptyOutput | "cleanup-empty-output" |
CleanupInvalidOutput | "cleanup-invalid-output" |
The three cleanup-* variants surface AI-cleanup failures distinctly
from recording-time failures — CLI / SDK consumers can map “the AI
couldn’t clean this trace” separately from “the recorder itself blew up”.
§Capture-side note
IR is captured from the smix API channel (host-side instrumentation
in RecordSession), not from sim-side AX notification swizzle. The
swizzle path was investigated and confirmed unable to surface user-tap
events from outside the smix API channel — “user taps sim screen
manually with smix watching” is a separate architecture and is not
currently supported.
§When to reach for this
| Use case | Pick |
|---|---|
| Want types only (build your own recorder/generator) | smix-recorder-ir |
| Want a working recorder + Rust/YAML code generation | smix-recorder (consumes this) |
| Want UI test scaffolding from scratch (no IR) | use smix-sdk directly |
§Scope
- ✅ 8 IR variants + RecorderErrorReason + sort helper
- ✅ Pure serde (camelCase tag, kebab-case error reasons)
- ✅ Stable
timestamp_ms()/kind()accessors - ❌ No recording I/O (use
smix-recorder) - ❌ No code generation (use
smix-recorder)
§License
Dual-licensed under either:
at your option. smix-recorder-ir — IRAction (intermediate representation) + RecorderError + sort helper (stone, cold path).
Ported from now-retired TS source: src/recorder/ir.ts (v2.0 c3 + v2.0 c4 cleanup
failure reasons). Each IRAction is one user-visible side-effecting
step in a recorded session; the IR feeds generator-smix-ts +
generator-maestro-yaml dual output (c{N}+ port).
Scope note (TS v2.0 c3): IR is captured from the smix API channel
(host-side instrumentation in RecordSession), not from sim-side AX
notification swizzle. The swizzle path was dug in v2.0 c2/c3 S1 and
confirmed unable to surface user-tap events from outside the smix API
channel. “User taps sim screen manually with smix watching” is a
separate architecture (v2.1 字面方向 paused — see docs/roadmap.md).
Structs§
- Recorder
Error - Recorder-side failure, distinct from SDK-side ExpectationFailure. CLI / SDK consumers may surface this directly or wrap with context.
Enums§
- IRAction
- One user-visible side-effecting step in a recorded session.
- Recorder
Error Reason - Reasons a recorder session might fail. v2.0 c4 extended with three
cleanup-*variants to surface claude-CLI AI-cleanup failures distinctly from the recording itself.
Functions§
- sort_
by_ timestamp - Sort actions by timestamp ascending. Idempotent. Used when multiple
recorders feed the same session (e.g. parallel cells, future feature)
to merge chronologically. Mirrors TS
sortByTimestamp1:1.