diff --git a/src/SUMMARY.md b/src/SUMMARY.md index ab46f8f..a376523 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -9,7 +9,8 @@ - [Business requirements](product/business-requirements.md) - [UX requirements](product/ux-requirements.md) - [Cost analysis](product/cost-analysis.md) -- [Roadmap](product/roadmap.md) +- [Phase 1 roadmap (OJT)](product/roadmap.md) +- [Phase 2 roadmap](product/phase-2-roadmap.md) # Architecture diff --git a/src/product/phase-2-roadmap.md b/src/product/phase-2-roadmap.md new file mode 100644 index 0000000..321af11 --- /dev/null +++ b/src/product/phase-2-roadmap.md @@ -0,0 +1,96 @@ +# Phase 2 roadmap + +Phase 1 (the [8-week OJT roadmap](roadmap.md), September to December 2026) ended with [PsyDian 0.1.0](https://github.com/PsyDianOS/PsyDian_OS/releases/tag/v0.1.0): a single-task kernel with a shell, structured diagnostics and an AI Bridge whose suggestions the kernel checks before anything runs. + +Phase 2 turns that kernel into an operating system that can run more than one thing at a time, keep programs apart from the kernel and from each other, and remember what happened across reboots. + +## Goals + +1. **Run several tasks at once** and switch between them on the timer. +2. **Separate user programs from the kernel** with their own privilege level and address space. +3. **Store data on a disk**, including the logs and diagnostics that today live only in memory. +4. **Load and run programs from that disk**, and move the shell out of the kernel. +5. **Keep the AI useful as the system grows**: diagnostics that name the task that failed, answers grounded in PsyDian's own documentation, and an offline option. + +The safety rule from Phase 1 does not change: the AI only suggests, the kernel checks, and the user decides. + +## Milestones + +Each milestone is a release. The work for each one is tracked as a [GitHub milestone](https://github.com/PsyDianOS/PsyDian_OS/milestones) with one tracking issue. + +| Release | Theme | Target | Done when | +|---|---|---|---| +| **0.2.0** | Multitasking | January 2027 | Two tasks run at the same time, `ps` lists them, and a fault names the task that caused it | +| **0.3.0** | User mode and system calls | February 2027 | A ring 3 program prints through a system call, and a bad memory access in it is reported without stopping the kernel | +| **0.4.0** | Storage and a file system | March 2027 | Files can be listed, read and written, and the logs survive a reboot | +| **0.5.0** | Programs from disk | April 2027 | The shell starts programs from the disk and itself runs in user mode | + +Dates are targets for two part-time developers, not promises. A milestone ships when its "done when" line is true and its tests pass. + +## Dependency order + +```text +0.1.0 single task + -> 0.2.0 tasks, context switch, scheduler + -> 0.3.0 ring 3, system calls, one address space per program + -> 0.4.0 disk driver, file system, persistent logs + -> 0.5.0 ELF loader, shell in user mode +``` + +Every later milestone needs multitasking: user programs are tasks, the disk driver waits for the device while other tasks run, and the AI request should not freeze the shell. + +## 0.2.0: Multitasking + +The 100 Hz timer (PIT channel 0, IRQ 0) already interrupts the CPU every 10 ms. Phase 2 uses that tick to share the CPU between tasks. + +| Work | Notes | +|---|---| +| Task structure and per-task kernel stacks | Each task gets its own stack with an unmapped guard page below it, so an overflow is a clean page fault | +| Context switch | Saves and restores the callee-saved registers and the stack pointer; written as a small `naked` function | +| Round-robin scheduler, cooperative first | `yield_now()` switches to the next ready task; an idle task runs `hlt` when nothing else is ready | +| Preemption on the timer | Every N ticks the timer handler switches tasks, after sending EOI | +| Task lifecycle | `spawn`, `exit`, `sleep(ms)` built on timer ticks | +| Locking rules | Critical sections and locks that are safe when a switch can happen at any tick | +| Shell commands | `ps` lists tasks and their state; `kill ` stops one | +| Diagnostics | Log records and diagnostic frames carry the task id | +| Tests | Two tasks interleave; a sleeping task wakes on time; a fault reports its task | + +## 0.3.0: User mode and system calls + +- Ring 3 code and data segments in the GDT, and the TSS `rsp0` stack used on every switch back to the kernel. +- `syscall` / `sysret` entry with a small system call table: `write`, `exit`, `sleep`, `getpid`. +- One page table per program, sharing the kernel's upper half, so programs cannot read each other's memory. +- A fault in user mode becomes a diagnostic and ends that program, not the kernel. + +## 0.4.0: Storage and a file system + +- A virtio block driver for QEMU's disk. +- A simple file system (FAT or a small PsyDian format, decided in an architecture decision record). +- Shell commands to list, read and write files. +- Logs and diagnostics written to disk, so the AI Bridge can look at history after a reboot. + +## 0.5.0: Programs from disk + +- An ELF loader that maps a program into its own address space and starts it in ring 3. +- The shell moves to user mode and starts programs by name. +- A tiny user-space library for programs (system call wrappers, `print`). + +## AI track + +The AI Bridge can move forward in parallel with the kernel milestones. + +| Work | Milestone | +|---|---| +| Include the failing task's id and name in the AI context | 0.2.0 | +| Local AI by default when Ollama is installed, so PsyDian works offline | 0.3.0 | +| Answers grounded in PsyDian's documentation and recent diagnostics (retrieval) | 0.4.0 | +| Use the diagnostic history saved on disk | 0.4.0 | +| Voice input and output (stretch) | later | + +## After Phase 2 + +UEFI boot and real hardware, more than one CPU core, networking, a graphical interface, and an on-device model so the AI can run inside the system without a host bridge. + +## How to help + +Pick an issue in the current milestone, or one labelled **good first issue**, and read the [contributing guide](https://github.com/PsyDianOS/PsyDian_OS/blob/main/CONTRIBUTING.md). Bigger design questions belong in [Discussions](https://github.com/orgs/PsyDianOS/discussions) before code.