# igis-v2

A second-generation, from-scratch operating system written in Rust. The first version
(2005) was a bare-metal front-end for a modem; the second is a
general personal system built on the same thesis: the kernel is a language runtime that
owns the machine, applications are source text compiled in the kernel, and everything runs
at ring 0 in one address space.

![igis-v2 desktop: terminal, calculator and desktop panel](docs/screenshots/desktop.png)

*Real QEMU framebuffer. The terminal is running `ifconfig dhcp`, `nslookup example.com`
and `net_probe dns`; Calculator is an ordinary source application, and the Desktop panel
belongs to the interpreted desktop shell.*

## Screenshots

These are unedited 1024×768 QEMU framebuffer captures, not mockups. The harnesses in
[`scripts/`](scripts/) reproduce them on a headless boot.

| Networking | Apps |
|---|---|
| ![Terminal showing ifconfig, nslookup and net_probe](docs/screenshots/network.png) | ![Apps pull-down with the application categories](docs/screenshots/apps.png) |

| Widgets | Editor |
|---|---|
| ![Widgets control gallery](docs/screenshots/widgets.png) | ![Editor with highlighted source](docs/screenshots/editor.png) |

| File Browser | Clock |
|---|---|
| ![File Browser icon grid over the image tree](docs/screenshots/browser.png) | ![Analog and digital clock window](docs/screenshots/clock.png) |

| Mounts |
|---|
| ![Mounts window serving a host directory at net/share/](docs/screenshots/mounts.png) |

*The Mounts window with a live mount: `lib/netfs.ig` is answering a host directory over
TCP, so `net/share/` is an ordinary filesystem to every other application.*

## Mounting a host directory

The kernel owns the namespace, the serialized request/reply slot and the mount's
lifetime; the filesystem protocol is ordinary application source (spec 0032,
[ADR 0065](adr/0065-mount-seam-in-kernel-protocol-in-applications.md)).

```sh
# on the host: serve any directory
python3 scripts/netfs_host.py --root ~/share --port 9000 --verbose

# the machine
cargo xtask run
```

Open **Apps ▸ Mounts**, enter `10.0.2.2:9000` and a keyword such as `share`, press
**Mount**, then use `net/share/` like any other tree: browse it, open a file in the
editor and save it in place (a sibling `.tmp` is renamed over the target), or close
the window to unmount. **Break locks** clears an operation the host never answered,
and the kernel also breaks one automatically after ten seconds.
`scripts/netmount_qmp.py` proves the whole path headlessly, from the host bytes after
a rename to the editor's save.

## Build a bootable USB stick

`cargo xtask usb` builds `build/igis-usb.img` (spec 0035,
[ADR 0070](adr/0070-one-stick-usb-storage.md)): a BIOS/UEFI hybrid ISO with GRUB and
the kernel, plus two appended ext2 partitions — 160 MiB `igis-apps` mounted read-only
and 256 MiB `igis-home` mounted writable. The image is about 461 MiB, so use a stick
of at least 1 GiB.

```sh
cargo xtask usb
sudo dd if=build/igis-usb.img of=/dev/sdX bs=4M status=progress conv=fsync
```

Replace `/dev/sdX` with the stick device (check it twice; `dd` overwrites the whole
device). No internal disk is needed: this is the one-stick path, and `/home` writes
persist across reboots.

The image is a BIOS/UEFI hybrid and both firmware paths boot to the desktop. The
kernel's boot identity map covers the first 1 TiB ([ADR 0071](adr/0071-static-1-tib-identity-map.md)),
so a UEFI firmware that assigns the xHCI BAR above 4 GiB is handled too: OVMF's
`0xc000000000` BAR is proved to `desktop_shell: ready`, and any BAR at or above the
1 TiB window is a named skip rather than a fault. The shipped image **requires xHCI**
(USB 3.x and USB 2 on modern machines). EHCI support is **blocked** (M28.5), so
EHCI-only machines do not boot it yet. **Secure Boot must be off** — the EFI GRUB
binary is unsigned. Input is PS/2 or the laptop's internal keyboard (there is no USB
HID keyboard driver), and networking is e1000/e1000e only. `cargo xtask usb --shell`
builds the test variant with the `tests/` corpus and the serial REPL.

## Releases

GitHub is the backup and the code host, not a build farm: the only workflow
([`.github/workflows/tests.yml`](.github/workflows/tests.yml)) runs the host test
suite on every push and pull request and publishes nothing. The bootable
artifacts are built locally and shipped by hand:

```sh
cargo xtask image    # build/igis.iso, build/apps.img, build/home.img
cargo xtask usb      # build/igis-usb.img (one stick)
```

A release is a tag plus those files, uploaded where you keep them:

```sh
git tag v0.1.0
git push origin v0.1.0
gzip -9 -f build/home.img build/apps.img && sha256sum build/igis.iso \
  build/apps.img.gz build/home.img.gz build/igis-usb.img \
  scripts/run-release.sh > SHA256SUMS
```

For the IDE/QEMU path keep `igis.iso`, `apps.img` and `home.img` in one
directory next to `scripts/run-release.sh` (as `run.sh`) and run it (QEMU and
`gunzip` required on the first run, which expands the two disks to their 160 MiB
and 256 MiB forms). Sound uses PulseAudio/PipeWire when a server is reachable;
set `IGIS_AUDIO=none` for a silent machine. The ISO contains only the kernel —
the application volume and `/home` are the two disk images — so all three files
are needed to boot the desktop.

For the one-stick path, write the USB image instead (xHCI, Secure Boot off; EHCI
is deferred):

```sh
sudo dd if=build/igis-usb.img of=/dev/sdX bs=4M status=progress conv=fsync
```

## Implementation

x86_64 first, with architecture-specific code isolated so other ISAs can follow
([ADR 0013](adr/0013-x86_64-first-multi-arch.md)). Boot is GRUB + multiboot2 with a
hand-written long-mode transition ([ADR 0014](adr/0014-grub-multiboot2-boot.md)).
Applications arrive on a read-only ext2 image ([ADR 0015](adr/0015-read-only-ext2-delivery.md))
and are advanced by per-core interpreter loops that claim work from a global set; nothing
is pinned ([ADR 0011](adr/0011-work-stealing-interpreters.md)). The shell is itself an
application: a kernel REPL service compiles it at boot and starts it, and applications
start others through a `run`/`spawn` request queue ([ADR 0017](adr/0017-repl-spawn-service.md)).

**Status: implementation.** Specs 0001–0035 are accepted; milestones M2–M28 are
complete except M28.5 (EHCI, blocked), which leaves the one-stick path xHCI-only
(desktop, language, filesystems, networking, terminal emulator, runtime display modes,
PNG/PPM image viewer, retained-surface composition, local client coordinates, the
large-icon file browser and its open-with/context-menu actions, audio output, user
filesystem mounts, task introspection and the one-stick USB boot), 859 host tests pass,
and ABI v1 has 75 opcodes. The read-only
160 MiB image tree carries a full-resolution PPM P6 corpus generated from the tracked
`samples/image-src` JPEGs (the generated PPMs are not committed; the PNG decoder is
retained), and `apps/accessories/image_viewer` opens both PNG (Adam7 pass-1) and PPM
(fixed-stride 1/8 sampling) without a full-image buffer. The four committed 32×32 icon
PPMs under `samples/icons/ppm` are loaded once from the read-only `icons/` directory and
drive the file browser's icon grid; `.ppm`/`.png` files open in the image viewer, `.txt`
files in the editor, and other files get a context menu with editor, terminal,
cut/copy/paste and delete actions. A Settings application changes the real display
mode through the QEMU `std` VGA Bochs VBE dispi (spec 0022, ADR 0056), and the Calendar
application shows the host month from the CMOS RTC (spec 0027). A host directory can be
mounted at `net/<keyword>/` and used like any other filesystem (spec 0032, ADR 0065):
the kernel owns only the namespace, the serialized request/reply slot and the lifetime,
while the protocol is ordinary application source — `lib/netfs.ig` on the guest side and
`scripts/netfs_host.py` on the host — so the editor saves a mount document in place. The
one-stick USB image carries the same application volume and `/home` as labelled ext2
partitions (spec 0035, [ADR 0070](adr/0070-one-stick-usb-storage.md)); xHCI is proved,
EHCI is blocked and opt-in. See [`AGENTS.md`](AGENTS.md) for the current state and
[`PLAN.md`](PLAN.md) for what is next.

| Document | Purpose |
|----------|---------|
| [`specs/0001-vision.md`](specs/0001-vision.md) | Start here: thesis, origin, goal, requirements. |
| [`AGENTS.md`](AGENTS.md) | Operational guide: current state, conventions, toolchain, layout. |
| [`PLAN.md`](PLAN.md) | Milestone plan, ticket backlog and deferred items. |
| [`specs/`](specs/README.md) | Normative specifications (what the system shall do). |
| [`adr/`](adr/README.md) | Architecture decision records (why, and what was rejected). |
| [`docs/language/`](docs/language/README.md) | Agent-oriented manual for the application language, `core`/`syslib`/`stdlib` and `/lib` modules. |
| [`docs/HISTORY.md`](docs/HISTORY.md) | Long-form narrative, decision index and dated status log. |
| [`OPEN-QUESTIONS.md`](OPEN-QUESTIONS.md) | Parked decisions and unresolved questions. |
| [`IDEAS.md`](IDEAS.md) | Unstructured inbox for ideas not yet worth designing. |
