# Layer 1 Foundation

Layer 1 provides the minimum native, verifiable foundation for a personal AI workstation.

- mise is the runtime source of truth.
- uv manages Python workflows but may not download or manage another Python installation.
- pnpm manages Node.js projects and the workbench; `pnpm setup` is not used.
- Python 3.14, Node.js 24 LTS, Go 1.26, and Rust 1.98.0 are the supported baseline.
- Project dependencies remain isolated; caches may be shared, dependency trees may not.
- Interactive `pip`, `npm`, `npx`, and `fnm` guardrails guide humans without intercepting scripts.

Preview and apply explicitly:

```powershell
afd layer1 --dry-run
afd layer1 --apply
.\scripts\01-verify-layer1.ps1
```

On Linux/WSL, the same `afd layer1` and `afd fix layer1` commands route to native POSIX adapters.
Runtimes remain user-scoped. Docker Engine is installed as a separate privileged host-tool step;
AFD never runs Layers 1–3 inside Docker and does not automatically grant the `docker` group.

## Doctor and controlled repair

`afd doctor` is the primary read-only troubleshooting command. It checks the active platform, managed PATH
precedence, no-profile shell resolution, mise/uv/pnpm, declared runtimes, uv policy, PNPM_HOME, the
physical uv WinGet location, profile markers, and Microsoft Store Python alias conflicts.
`afd doctor --json` emits schema version 1 with category, severity, code, sanitized evidence, and
suggestion. Neither mode writes logs, state, backups, profiles, PATH, or installations.

The TypeScript doctor separately reports the Node runtime hosting AFD and the managed `node`
resolved from the effective process PATH. Every managed command is executed with a bounded
`--version` probe; file presence alone is not a pass. It also identifies hybrid sandbox contexts
where the process token, declared user, and profile path disagree. `afd fix layer1` fails closed in
that context instead of modifying the wrong HKCU or profile.

`afd fix layer1 --dry-run` shows the reconciliation plan. `--apply` reconciles only AFD-managed
Layer 1 state and reruns doctor, returning non-zero while critical failures remain. Existing profiles
are backed up only before a real change under `%LOCALAPPDATA%\AI Foundry Desk\backups`.

AFD may place its mise shims entry first in user PATH so it wins over the Microsoft Store Python
alias. It does not disable Windows App Execution Aliases. Third-party runtimes, projects,
dependencies, credentials, services, agents, skills, and Layer 2 remain outside repair scope.

`01-verify-layer1.ps1` remains the compact verifier used by `afd verify`; doctor explains and fix
explicitly reconciles.

The installer persists `UV_NO_MANAGED_PYTHON=1`, `UV_PYTHON_DOWNLOADS=0`, `PNPM_HOME`, mise shims,
and the required command paths. It does not set persistent `UV_SYSTEM_PYTHON`, `UV_PYTHON`, weaken
execution/TLS controls, or approve third-party scripts. Review untrusted repositories in a
disposable VM or Windows Sandbox without personal credentials or synchronized folders.
