# badinkajink/modified-code-as-policies architecture

> Architecture diagram of the GitHub repository badinkajink/modified-code-as-policies, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/badinkajink/modified-code-as-policies
- Repository: https://github.com/badinkajink/modified-code-as-policies

## Overview

This repository combines modified Code-as-Policies prompt designs with RobotPy examples and a small Codex web demo. The intended user journey is natural-language instruction to generated robot policy; the demo server visibly submits a prompt template to OpenAI and returns completion text. Robot control, autonomous routines, and simulation form separate implementation branches. Source excerpts establish the Romi and swerve wiring, but do not show a complete generated-policy-to-robot execution path, so that link is omitted.

Main entry points: [`codex_robotpy/romi/subsystems/drivetrain.py`](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/subsystems/drivetrain.py) (Romi drivetrain), [`codex_robotpy/romi/robotcontainer.py`](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/robotcontainer.py) (Command configuration), [`codex_robotpy/demo-site/server.py`](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/demo-site/server.py) (Generation server), [`codex_robotpy/swerve_robot.py`](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/swerve_robot.py) (Swerve robot)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_policy["Policy prompts"]
  node_tabletop["Tabletop policies<br/>[tabletop_prompt.py]"]
  node_interactive["Interactive policies"]
  node_unaware["Unaware policies"]
  node_romi_prompt["Simulated Romi prompt"]
end

subgraph group_demo["Web demo"]
  node_web_prompt["Demo prompt"]
  node_web_server["Generation server<br/>[server.py]"]
end

subgraph group_romi["Romi robot"]
  node_romi_robot["Romi lifecycle<br/>[robot.py]"]
  node_container["Command configuration<br/>[robotcontainer.py]"]
  node_romi_drive["Romi drivetrain<br/>[drivetrain.py]"]
  node_arcade["Arcade drive<br/>[arcadedrive.py]"]
  node_auto_distance["Distance auto"]
  node_auto_time["Timed auto<br/>[autonomous_time.py]"]
  node_drive_distance["Drive distance<br/>[drivedistance.py]"]
  node_drive_time["Drive timed<br/>[drivetime.py]"]
  node_turn_degrees["Turn degrees<br/>[turndegrees.py]"]
  node_turn_time["Turn timed<br/>[turntime.py]"]
  node_romi_sim["Romi simulation<br/>[physics.py]"]
end

subgraph group_swerve["Swerve robot"]
  node_swerve_robot["Swerve robot<br/>[swerve_robot.py]"]
  node_components["Swerve drivetrain<br/>[drivetrain.py]"]
  node_driverstation["Driver controls<br/>[driverstation.py]"]
  node_sensors["Robot sensors<br/>[sensors.py]"]
  node_autonomous["Swerve autonomous<br/>[testAuto.py]"]
  node_swerve_sim["Swerve simulation<br/>[swerve_physics.py]"]
end

node_instructor(("Robot user"))
node_codex{{"OpenAI Codex API"}}
node_ur5["UR5 in PyBullet"]

node_instructor -->|"submits instruction"| node_web_server
node_web_server -->|"prefixes prompt"| node_web_prompt
node_web_server -->|"requests completion"| node_codex
node_web_server -->|"returns completion"| node_instructor
node_romi_robot -->|"creates"| node_container
node_container -->|"creates"| node_romi_drive
node_container -->|"configures default"| node_arcade
node_container -->|"offers routine"| node_auto_distance
node_container -->|"offers routine"| node_auto_time
node_arcade -->|"drives"| node_romi_drive
node_auto_distance -->|"sequences"| node_drive_distance
node_auto_distance -->|"sequences"| node_turn_degrees
node_auto_time -->|"sequences"| node_drive_time
node_auto_time -->|"sequences"| node_turn_time
node_drive_distance -->|"uses"| node_romi_drive
node_drive_time -->|"uses"| node_romi_drive
node_turn_degrees -->|"uses"| node_romi_drive
node_turn_time -->|"uses"| node_romi_drive
node_swerve_robot -->|"uses"| node_components
node_swerve_robot -->|"uses"| node_driverstation
node_swerve_robot -->|"uses"| node_sensors
node_autonomous -->|"commands"| node_components
node_romi_sim -->|"simulates"| node_romi_robot
node_swerve_sim -->|"simulates"| node_swerve_robot
node_swerve_sim -->|"uses"| node_components
node_instructor -.->|"instructs"| node_tabletop
node_instructor -.->|"instructs"| node_interactive
node_instructor -.->|"instructs"| node_unaware
node_romi_prompt -.->|"targets policy runtime"| node_romi_robot
node_ur5 -.->|"receives policies"| node_instructor

click node_tabletop "https://github.com/badinkajink/modified-code-as-policies/blob/master/qqa/tabletop_prompt.py"
click node_interactive "https://github.com/badinkajink/modified-code-as-policies/blob/master/qqa/full_interactive_tabletop_prompt.py"
click node_unaware "https://github.com/badinkajink/modified-code-as-policies/blob/master/qqa/unaware_tabletop_prompt.py"
click node_romi_prompt "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/autonomous/simulated_romi_prompt.py"
click node_web_prompt "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/demo-site/simulated_romi_prompt.py"
click node_web_server "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/demo-site/server.py"
click node_romi_robot "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/robot.py"
click node_container "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/robotcontainer.py"
click node_romi_drive "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/subsystems/drivetrain.py"
click node_arcade "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/commands/arcadedrive.py"
click node_auto_distance "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/commands/autonomous_distance.py"
click node_auto_time "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/commands/autonomous_time.py"
click node_drive_distance "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/commands/drivedistance.py"
click node_drive_time "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/commands/drivetime.py"
click node_turn_degrees "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/commands/turndegrees.py"
click node_turn_time "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/commands/turntime.py"
click node_swerve_robot "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/swerve_robot.py"
click node_components "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/components/drivetrain.py"
click node_driverstation "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/components/driverstation.py"
click node_sensors "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/components/sensors.py"
click node_autonomous "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/magicbot_autonomous/testAuto.py"
click node_romi_sim "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/physics.py"
click node_swerve_sim "https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/swerve_physics.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_tabletop,node_interactive,node_unaware,node_romi_prompt,node_instructor toneBlue
class node_web_prompt,node_web_server toneAmber
class node_romi_robot,node_container,node_romi_drive,node_arcade,node_auto_distance,node_auto_time,node_drive_distance,node_drive_time,node_turn_degrees,node_turn_time,node_romi_sim,node_codex toneMint
class node_swerve_robot,node_components,node_driverstation,node_sensors,node_autonomous,node_swerve_sim toneRose
class node_ur5 toneIndigo
```

## Components

### Policy prompts

- [Tabletop policies](https://github.com/badinkajink/modified-code-as-policies/blob/master/qqa/tabletop_prompt.py): `qqa/tabletop_prompt.py`
- [Interactive policies](https://github.com/badinkajink/modified-code-as-policies/blob/master/qqa/full_interactive_tabletop_prompt.py): `qqa/full_interactive_tabletop_prompt.py`
- [Unaware policies](https://github.com/badinkajink/modified-code-as-policies/blob/master/qqa/unaware_tabletop_prompt.py): `qqa/unaware_tabletop_prompt.py`
- [Simulated Romi prompt](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/autonomous/simulated_romi_prompt.py): `codex_robotpy/autonomous/simulated_romi_prompt.py`

### Web demo

- [Demo prompt](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/demo-site/simulated_romi_prompt.py): `codex_robotpy/demo-site/simulated_romi_prompt.py`
- [Generation server](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/demo-site/server.py): `codex_robotpy/demo-site/server.py`

### Romi robot

- [Romi lifecycle](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/robot.py): `codex_robotpy/romi/robot.py`
- [Command configuration](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/robotcontainer.py): `codex_robotpy/romi/robotcontainer.py`
- [Romi drivetrain](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/subsystems/drivetrain.py): `codex_robotpy/romi/subsystems/drivetrain.py`
- [Arcade drive](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/commands/arcadedrive.py): `codex_robotpy/romi/commands/arcadedrive.py`
- [Distance auto](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/commands/autonomous_distance.py): `codex_robotpy/romi/commands/autonomous_distance.py`
- [Timed auto](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/commands/autonomous_time.py): `codex_robotpy/romi/commands/autonomous_time.py`
- [Drive distance](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/commands/drivedistance.py): `codex_robotpy/romi/commands/drivedistance.py`
- [Drive timed](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/commands/drivetime.py): `codex_robotpy/romi/commands/drivetime.py`
- [Turn degrees](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/commands/turndegrees.py): `codex_robotpy/romi/commands/turndegrees.py`
- [Turn timed](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/romi/commands/turntime.py): `codex_robotpy/romi/commands/turntime.py`
- [Romi simulation](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/physics.py): `codex_robotpy/physics.py`

### Swerve robot

- [Swerve robot](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/swerve_robot.py): `codex_robotpy/swerve_robot.py`
- [Swerve drivetrain](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/components/drivetrain.py): `codex_robotpy/components/drivetrain.py`
- [Driver controls](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/components/driverstation.py): `codex_robotpy/components/driverstation.py`
- [Robot sensors](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/components/sensors.py): `codex_robotpy/components/sensors.py`
- [Swerve autonomous](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/magicbot_autonomous/testAuto.py): `codex_robotpy/magicbot_autonomous/testAuto.py`
- [Swerve simulation](https://github.com/badinkajink/modified-code-as-policies/blob/master/codex_robotpy/swerve_physics.py): `codex_robotpy/swerve_physics.py`

### Other components

- **Robot user**
- **OpenAI Codex API**
- **UR5 in PyBullet**

## Connections

- Robot user → Generation server: submits instruction (evidence: `codex_robotpy/demo-site/server.py`)
- Generation server → Demo prompt: prefixes prompt (evidence: `codex_robotpy/demo-site/server.py`)
- Generation server → OpenAI Codex API: requests completion (evidence: `codex_robotpy/demo-site/server.py`)
- Generation server → Robot user: returns completion (evidence: `codex_robotpy/demo-site/server.py`)
- Romi lifecycle → Command configuration: creates (evidence: `codex_robotpy/romi/robot.py`)
- Command configuration → Romi drivetrain: creates (evidence: `codex_robotpy/romi/robotcontainer.py`)
- Command configuration → Arcade drive: configures default (evidence: `codex_robotpy/romi/robotcontainer.py`)
- Command configuration → Distance auto: offers routine (evidence: `codex_robotpy/romi/robotcontainer.py`)
- Command configuration → Timed auto: offers routine (evidence: `codex_robotpy/romi/robotcontainer.py`)
- Arcade drive → Romi drivetrain: drives (evidence: `codex_robotpy/romi/robotcontainer.py`)
- Distance auto → Drive distance: sequences (evidence: `codex_robotpy/romi/commands/autonomous_distance.py`)
- Distance auto → Turn degrees: sequences (evidence: `codex_robotpy/romi/commands/autonomous_distance.py`)
- Timed auto → Drive timed: sequences (evidence: `codex_robotpy/romi/commands/autonomous_time.py`)
- Timed auto → Turn timed: sequences (evidence: `codex_robotpy/romi/commands/autonomous_time.py`)
- Drive distance → Romi drivetrain: uses (evidence: `codex_robotpy/romi/commands/drivedistance.py`)
- Drive timed → Romi drivetrain: uses (evidence: `codex_robotpy/romi/commands/drivetime.py`)
- Turn degrees → Romi drivetrain: uses (evidence: `codex_robotpy/romi/commands/turndegrees.py`)
- Turn timed → Romi drivetrain: uses (evidence: `codex_robotpy/romi/commands/turntime.py`)
- Swerve robot → Swerve drivetrain: uses (evidence: `codex_robotpy/swerve_robot.py`)
- Swerve robot → Driver controls: uses (evidence: `codex_robotpy/swerve_robot.py`)
- Swerve robot → Robot sensors: uses (evidence: `codex_robotpy/swerve_robot.py`)
- Swerve autonomous → Swerve drivetrain: commands (evidence: `codex_robotpy/magicbot_autonomous/testAuto.py`)
- Romi simulation → Romi lifecycle: simulates (evidence: `codex_robotpy/physics.py`)
- Swerve simulation → Swerve robot: simulates (evidence: `codex_robotpy/swerve_physics.py`)
- Swerve simulation → Swerve drivetrain: uses (evidence: `codex_robotpy/swerve_physics.py`)
- Robot user → Tabletop policies: instructs (evidence: `README.md`)
- Robot user → Interactive policies: instructs (evidence: `README.md`)
- Robot user → Unaware policies: instructs (evidence: `README.md`)
- Simulated Romi prompt → Romi lifecycle: targets policy runtime
- UR5 in PyBullet → Robot user: receives policies (evidence: `README.md`)
