PureSim implements a dual-console architecture with strict separation of concerns:
- Virtual Serial Terminal (PuTTY-like) — Simulates a serial connection to Purity OS
- Quake-Style Developer Console — Overlay for simulator control and debugging
These two consoles have non-overlapping purposes and must never be conflated.
Simulates a real serial connection to Pure Storage equipment running Purity (Ubuntu-based OS). All operational commands that would exist on a real serial session belong here.
- Emulates TTY device with line discipline, echo, and history
- Commands execute against simulated Purity OS
- Outputs must mirror real logs from
Docs/PuttyLogs/and command PDFs - Examples:
mount,umount,ls,purearray,purehw,puresetup
- Namespace:
PureSim.Serial.* - Location:
Assets/Scripts/Serial/ - Interface:
ISerialCommand - Attribute:
[SerialCommand("name")]
[SerialCommand("mount")]
public class MountCommand : ISerialCommand
{
public void Execute(SimulationState sim, string[] args, ISerialOutput terminal)
{
// Source: Docs/PuttyLogs/putty2025-02-18.log L650-653
if (!sim.IsUsbInserted() && device.Contains("sdb"))
{
terminal.WriteLine("mount: special device /dev/sdb1 does not exist");
return;
}
// ... implementation mirrors real behavior
}
}Overlay console for simulator control only. Controls workflow steps, fault injection, simulation diagnostics, and USB state toggling. No operational/array commands here.
- Toggles with backquote/tilde (
~) - Overlay UI with scrollback, history, and autocomplete
- Commands manipulate
SimulationStateandWorkflowEngine - Examples:
jump,steps,inject,clearfault,usb state
- Namespace:
PureSim.Console.* - Location:
Assets/Scripts/Console/ - Interface:
IConsoleCommand - Attribute:
[ConsoleCommand("name")]
[ConsoleCommand("jump")]
public class JumpCommand : IConsoleCommand
{
public void Execute(SimulationState sim, string[] args, IConsoleOutput output)
{
if (workflowEngine.CanJumpToStep(stepId, sim, out var failed))
{
workflowEngine.JumpToStep(stepId, sim);
output.WriteSuccess($"Jumped to step: {stepId}");
}
else
{
output.WriteError("Cannot jump - missing preconditions:");
// ... report failed preconditions
}
}
}✅ Allowed:
- Workflow control:
jump,steps - Fault injection:
inject,clearfault,faults - State control:
usb state inserted,usb state removed - Diagnostics:
diag sim,diag power,diag ports - Meta:
help,clear,history
❌ Forbidden:
- Any command that would exist on real Purity OS
- Examples:
mount,lsblk,purearray,purehw,apt,dmesg
✅ Allowed:
- Linux utilities:
ls,mount,umount,lsblk,dmesg - Purity commands:
purearray,purehw,puredrive,puresetup - Package management:
apt, file operations, networking
❌ Forbidden:
- Simulator control commands
- Examples:
jump,inject,steps,usb state
Boundary separation is enforced through:
-
Interface Separation
IConsoleCommandvsISerialCommandare distinct interfaces- Commands implement only one interface
-
Namespace Separation
- Console:
PureSim.Console.* - Serial:
PureSim.Serial.*
- Console:
-
Attribute Separation
- Console:
[ConsoleCommand("name")] - Serial:
[SerialCommand("name")]
- Console:
-
Test Enforcement
ConsoleBoundaryTests.csverifies no cross-contamination- Tests fail if operational commands appear in console registry
# Run in Unity Test Runner (Edit Mode)
Assets/Tests/Editor/Console/ConsoleParserTests.cs
Assets/Tests/Editor/ConsoleBoundaryTests.csSerial commands include golden transcript tests with expected output:
Assets/Tests/PlayMode/Serial/Golden_Lsblk_and_Mount.txt
Each test references source logs:
# Source: Docs/PuttyLogs/putty2025-02-18.log L648-653
Command: ls /dev/sd*1
Expected Output:
/dev/sda1 /dev/sdb1
- Create file in
Assets/Scripts/Console/Commands/ - Implement
IConsoleCommandinterface - Add
[ConsoleCommand("name")]attribute - Implement command logic using
SimulationStateandWorkflowEngine - Command auto-registers via reflection
- Create file in
Assets/Scripts/Serial/Commands/ - Implement
ISerialCommandinterface - Add
[SerialCommand("name")]attribute - Search logs/PDFs for authentic output
- Add source citations in code comments
- Implement happy path and error paths
- Add golden transcript test case
- SimulationState — Single source of truth (arrays, USB, faults, power)
- WorkflowEngine — Workflow steps with precondition guards
- EventBus — Pub/sub for state changes (future)
- HardwareModel — Typed components and relationships (future)
- ConsoleController — Input, parsing, dispatch, history, autocomplete
- ConsoleRegistry — Reflection-based command discovery
- ConsoleOutput — Formatted output with colors and tables
- SerialTerminal — Terminal emulator with line discipline (future)
- SerialDispatcher — Command routing (future)
- SerialOutput — Terminal output interface
> help
Available Console Commands:
jump <step_id>
Jump to a specific workflow step
inject <fault_id> [description]
Inject a fault into the simulation
> steps
Workflow Steps:
► [usb-detect] USB Detection
○ [device-select] Device Selection
✗ [mount] Mount USB (blocked: usb-inserted)
> usb state inserted
USB inserted
Device: /dev/sdb1
> jump mount
Jumped to step: Mount USB (mount)
puresetup@PCTFJ243000F4:~$ ls /dev/sd*1
/dev/sda1 /dev/sdb1
puresetup@PCTFJ243000F4:~$ mount /dev/sdb1 /mnt
puresetup@PCTFJ243000F4:~$ ls /mnt
purity_6.5.9_202412120507+7a7df3f70616.ppkg
purity_6.5.9_202412120507+7a7df3f70616.ppkg.sha1
- Repository Instructions:
.github/copilot-instructions.md - Change Log:
change log.MD - Authoritative Logs:
Docs/PuttyLogs/*.log - Command PDFs:
Docs/*.pdf - Design Document:
Docs/Design.md
Q: Can I add a reboot command to the Console?
A: No. reboot is an operational command that exists on real systems. It belongs in the Serial Terminal. Console commands are for simulator control only (e.g., jump, inject).
Q: Can I add a debug command to the Serial Terminal?
A: Only if it exists on real Purity systems. If you want simulator debugging, add it to Console instead (e.g., diag sim).
Q: How do I test my new command?
A: Add unit tests to Assets/Tests/Editor/ for logic, and golden transcript tests to Assets/Tests/PlayMode/ for Serial commands.
Q: Where do I find authentic command output?
A: Search Docs/PuttyLogs/*.log files and reference PDFs in Docs/. Always cite sources in comments.
Q: The console command isn't showing up?
A: Ensure you have:
[ConsoleCommand("name")]attributeIConsoleCommandinterface implemented- Public parameterless constructor
- Correct namespace (
PureSim.Console)
Last Updated: 2025-10-21