Skip to content

Commit ba1c349

Browse files
mios-devclaude
andcommitted
RESTRUCTURE: three-layer profile, multi-user skel, AI surface trim, CI fix
Three-layer profile + env model. Each layer overlays the one above it field-by-field; user-set fields supersede defaults; empty strings do not override non-empty layers below. Profile layers (highest precedence first): ~/.config/mios/profile.toml per-user (skel-seeded) /etc/mios/profile.toml host (mios-bootstrap) /usr/share/mios/profile.toml vendor defaults (THIS REPO) ← NEW Env layers: ~/.config/mios/env, /etc/mios/install.env, /etc/mios/env.d/*.env, /usr/share/mios/env.defaults ← NEW ~/.env.mios is kept as a deprecated legacy fallback. New mios.git files: - usr/share/mios/profile.toml — vendor defaults TOML, full field shape (identity, locale, auth, network, ai, desktop, image, bootstrap, quadlets.enable). Immutable per USR-OVER-ETC; bootstrap overlays. - usr/share/mios/env.defaults — vendor env defaults. AI surface restructure (minimum OpenAI-API patterns; retain code): - system.md (29 KB canonical agent prompt) moved from repo root to usr/share/mios/ai/system.md (FHS-correct vendor location). Repo-root /system.md is now a symlink to that path for off-host fallback; .gitignore re-whitelists the symlink. - Header sanitized: dropped "Claude Code, Gemini Code, Codex, Cursor, Aider, Continue" CLI list (vendor brand prose). Replaced with "AGENTS.md-aware CLI agents". Deployment-paths table extended to include /system.md symlink and ~/.config/mios/system-prompt.md per-user override. - Dropped duplicates/stale: usr/share/mios/ai/v1/{system.md,context.json, knowledge.md}. context.json referenced an obsolete /v1/system endpoint; v1/system.md duplicated the canonical; v1/knowledge.md duplicated INDEX.md/ARCHITECTURE.md/ENGINEERING.md. - Kept v1/models.json and v1/mcp.json (the actual OpenAI-API surface). CI build fix: - Containerfile: `find /var -mindepth 1 -maxdepth 1 ! -name tmp -exec rm -rf` now also excludes `cache`. /var/cache/{libdnf5,dnf} are buildkit cache mounts (--mount=type=cache) and are still bound during the RUN, so rm returned EBUSY and failed the build. Buildkit doesn't bake cache mounts into the layer regardless. Sanitization (vendor brand + emoji decoration + marketing prose): - automation/ai-bootstrap.sh: replace 🚀/📜/📄/📖/🧠/🌱/✅ with bracketed log-level prefixes; add file header. - usr/share/mios/PACKAGES.md: drop 🌐 emoji header and 📚 ecosystem block; consolidate ecosystem links to a clean reference list. - .github/ai-instructions.md: drop 🤝/🤖/🛠 emoji headers; rewrite to vendor-agnostic, FHS-cited prose. - tools/README.md: drop the [NET] MiOS Artifact / Proprietor preamble + json:knowledge sidebar + ecosystem footer. Reference LICENSES.md / CONTRIBUTING.md instead. - tools/log-to-bootstrap.sh, tools/mios-overlay.sh: replace ❌/✅/⚠️ with [ OK ] / WARN: / ERROR: bracket prefixes. Doc updates: - CLAUDE.md: dual-repo split table now lists exact deployed-system paths and their owner repo (vendor defaults vs. user overrides vs. per-user templates). - INDEX.md §4 (renamed from "Environment contract" to "Profile + environment resolution"): documents the three-layer profile and five-layer env resolution explicitly. Final brand-mention sweep: clean across both repos. The two surviving hits in usr/share/mios/ai/system.md (lines 297, 326) are inside the forbidden-token rule definition itself — meta-prose, expected per §6. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 70c780f commit ba1c349

17 files changed

Lines changed: 884 additions & 830 deletions

.github/ai-instructions.md

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
11
# MiOS AI Integration — GitHub Instructions
22

3-
Welcome to the **MiOS** repository. This project is a bootc-based, AI-native immutable workstation.
3+
MiOS is a bootc-based, AI-native immutable workstation. AI agents
4+
contributing to this repo must follow the rules in `INDEX.md` and the
5+
canonical agent prompt at `usr/share/mios/ai/system.md`.
46

5-
## 🤝 Contribution Rules for AI Agents
6-
1. **Architectural Integrity:** All changes must comply with the "Immutable Appliance Laws" in `INDEX.md`.
7-
2. **OpenAI Native:** Maintain compatibility with the local OpenAI-API surface at `http://localhost:8080/v1`.
8-
3. **FHS Compliance:** Ensure all filesystem overlays follow Linux FHS 3.0.
9-
4. **Documentation:** Every new feature or blueprint must include a `json:knowledge` block in its Markdown header.
7+
## Contribution rules for AI agents
108

11-
## 🤖 Integration Points
12-
- **System Prompt:** `system-prompt.md`
13-
- **AI Agent Hub:** `INDEX.md`
14-
- **Context Discovery:** `llms.txt`
15-
- **RAG Snapshot:** `artifacts/repo-rag-snapshot.json.gz`
9+
1. **Architectural laws:** changes must comply with the six laws listed
10+
in `INDEX.md` §3.
11+
2. **OpenAI v1 compatibility:** preserve the local OpenAI-compatible
12+
surface at `http://localhost:8080/v1`.
13+
3. **FHS 3.0:** filesystem overlays follow the Filesystem Hierarchy
14+
Standard 3.0 (<https://refspecs.linuxfoundation.org/FHS_3.0/>).
15+
4. **Sanitization:** persisted artifacts comply with
16+
`usr/share/mios/ai/system.md` §6 — no vendor brand prose, no chat
17+
metadata, no foreign sandbox path traces.
1618

17-
## 🛠 Quick Actions
18-
- **Validate Image:** `just build`
19-
- **Sync Knowledge:** `./automation/ai-bootstrap.sh`
20-
- **Check Linting:** `bootc container lint`
19+
## Integration points
20+
21+
- **Canonical system prompt:** `usr/share/mios/ai/system.md`
22+
(host override: `/etc/mios/ai/system-prompt.md`,
23+
per-user: `~/.config/mios/system-prompt.md`).
24+
- **Architectural index:** `INDEX.md`.
25+
- **AI ingestion index:** `llms.txt`, `llms-full.txt`.
26+
27+
## Quick actions
28+
29+
- Validate image: `just build` (Containerfile final RUN is `bootc container lint`).
30+
- Refresh AI manifests: `./automation/ai-bootstrap.sh`.
31+
- Re-run lint on built image: `just lint`.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
!/README.md
3838
!/SECURITY.md
3939
!/SELF-BUILD.md
40+
!/system.md
4041
!/VERSION
4142
!/llms-full.txt
4243
!/llms.txt

CLAUDE.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,24 @@ so bootc pre-pulls it offline.
124124
This repo (`mios.git`) and `mios-bootstrap.git` resolve to the same physical
125125
root on the dev host but each gitignore whitelists a *different subset*. The
126126
`.gitignore` here is a **whitelist inverter**`/*` ignores everything,
127-
then `!/path` re-includes the system-overlay subset. When committing, verify
128-
each path matches a negation; an untracked file outside the whitelist is
129-
correct gitignore behavior, not "a file to add". User/installer files
130-
(`/etc/mios/manifest.json`, user-account skeleton, knowledge graphs) belong
131-
in `mios-bootstrap.git`, not here.
127+
then `!/path` re-includes the system-overlay subset.
128+
129+
| Path on deployed system | Owner repo | Purpose |
130+
|---|---|---|
131+
| `/usr/share/mios/profile.toml` | `mios.git` | vendor profile defaults (immutable) |
132+
| `/usr/share/mios/env.defaults` | `mios.git` | vendor env defaults |
133+
| `/usr/share/mios/ai/system.md` | `mios.git` | canonical agent prompt |
134+
| `/etc/mios/profile.toml` | `mios-bootstrap.git` | host/admin profile overrides |
135+
| `/etc/mios/install.env` | `mios-bootstrap.git` | runtime identity (written at install) |
136+
| `/etc/mios/ai/system-prompt.md` | `mios-bootstrap.git` | host AI prompt override |
137+
| `/etc/skel/.config/mios/profile.toml` | `mios-bootstrap.git` | per-user TOML template |
138+
| `/etc/skel/.config/mios/system-prompt.md` | `mios-bootstrap.git` | per-user AI prompt template |
139+
140+
When committing to `mios.git`, verify each path matches a whitelist
141+
negation; an untracked file outside the whitelist is correct gitignore
142+
behavior, not "a file to add". User-installer files (`/etc/mios/*`,
143+
`/etc/skel/.config/mios/*`, knowledge graphs) belong in
144+
`mios-bootstrap.git`, not here.
132145

133146
## Architectural laws (from INDEX.md / .cursorrules — non-negotiable)
134147

Containerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ RUN --mount=type=bind,from=ctx,source=/ctx,target=/ctx,ro \
4949
CTX=/tmp/build /tmp/build/automation/build.sh; \
5050
dnf clean all; \
5151
rm -rf /tmp/build; \
52-
find /var -mindepth 1 -maxdepth 1 ! -name tmp -exec rm -rf {} +; \
52+
# /var/cache is bind-mounted by buildkit (--mount=type=cache above) for
53+
# the duration of this RUN, so trying to rm it returns EBUSY. Skip it;
54+
# buildkit doesn't bake cache mounts into the layer regardless.
55+
find /var -mindepth 1 -maxdepth 1 ! -name tmp ! -name cache -exec rm -rf {} +; \
5356
find /run -mindepth 1 -maxdepth 1 ! -name "secrets" -exec rm -rf {} + 2>/dev/null || true
5457

5558
RUN bootc completion bash > /etc/bash_completion.d/bootc

INDEX.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,33 @@ Spec: <https://platform.openai.com/docs/api-reference>.
3434
| 5 | **UNIFIED-AI-REDIRECTS**`MIOS_AI_KEY`, `MIOS_AI_MODEL`, `MIOS_AI_ENDPOINT``http://localhost:8080/v1`. No vendor URLs. | `usr/bin/mios`, `etc/mios/ai/` |
3535
| 6 | **UNPRIVILEGED-QUADLETS** — every Quadlet declares `User=`, `Group=`, `Delegate=yes`. Documented exceptions: `mios-ceph` and `mios-k3s` declare `User=root`/`Group=root` because Ceph/K3s require uid 0 (see file headers). | `etc/containers/systemd/`, `usr/share/containers/systemd/` |
3636

37-
## 4. Environment contract
37+
## 4. Profile + environment resolution
38+
39+
Both the user profile (TOML) and runtime environment (env-style) follow a
40+
three-layer overlay. Higher layers supersede lower layers field-by-field.
41+
42+
**Profile layers** (read by `mios-bootstrap/install.sh:load_profile_defaults`
43+
and at runtime by `mios` CLI clients):
44+
45+
1. `~/.config/mios/profile.toml` — per-user override (highest precedence;
46+
seeded into every uid≥1000 home from `/etc/skel/.config/mios/profile.toml`)
47+
2. `/etc/mios/profile.toml` — host/admin override (shipped by `mios-bootstrap`)
48+
3. `/usr/share/mios/profile.toml` — vendor defaults (shipped by `mios.git`,
49+
immutable, USR-OVER-ETC)
50+
51+
**Environment layers** (resolved by `/etc/profile.d/mios-env.sh` at login):
52+
53+
1. `~/.config/mios/env`
54+
2. `/etc/mios/install.env` (written by bootstrap install.sh)
55+
3. `/etc/mios/env.d/*.env` (admin/distro drop-ins)
56+
4. `/usr/share/mios/env.defaults` (vendor defaults)
57+
5. `~/.env.mios` (legacy, deprecated; kept for backwards compatibility)
58+
59+
**Build-time variables** read by `Justfile`:
3860

3961
| Variable | Scope | Purpose |
4062
|---|---|---|
41-
| `MIOS_AI_KEY` | AI | Local inference key (default empty for unauthenticated localhost). |
42-
| `MIOS_AI_MODEL` | AI | Target model id resolved via `usr/share/mios/ai/v1/models.json`. |
43-
| `MIOS_AI_ENDPOINT` | AI | API base URL. Default `http://localhost:8080/v1`. |
63+
| `MIOS_AI_KEY` / `MIOS_AI_MODEL` / `MIOS_AI_ENDPOINT` | AI | Resolution per LAW 5; defaults in `usr/share/mios/env.defaults`. |
4464
| `MIOS_BASE_IMAGE` | build | OCI base image (default `ghcr.io/ublue-os/ucore-hci:stable-nvidia`, `Justfile:45`). |
4565
| `MIOS_LOCAL_TAG` | build | Local image tag (default `localhost/mios:latest`, `Justfile:13`). |
4666
| `MIOS_USER` / `MIOS_HOSTNAME` | build | Default account/hostname baked into the image (`Containerfile:26-27`). |

automation/ai-bootstrap.sh

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,71 @@
11
#!/bin/bash
2-
# MiOS Omni-Agent Bootstrap Script
3-
# Synchronizes manifests and initializes sub-project environments.
2+
# MiOS AI/manifest bootstrap. Regenerates directory manifests, syncs the Wiki,
3+
# rebuilds the unified knowledge base (RAG snapshot), refreshes user-space
4+
# environment configs, and seeds shared agent context. Idempotent.
45

56
set -euo pipefail
67

7-
echo "🚀 Initializing MiOS Agent Workspace..."
8+
echo "[ai-bootstrap] Initializing MiOS agent workspace..."
89

9-
# 0. Load Unified Environment
10+
# 0. Load unified environment (legacy .env.mios; deprecated — prefer
11+
# /etc/mios/profile.toml for new installs).
1012
if [[ -f ".env.mios" ]]; then
11-
echo "📜 Loading unified environment from .env.mios..."
12-
# Export all variables defined in .env.mios
13+
echo "[ai-bootstrap] Loading legacy environment from .env.mios..."
1314
set -a
15+
# shellcheck disable=SC1091
1416
source .env.mios
1517
set +a
1618
fi
1719

18-
# 1. Generate Manifests
20+
# 1. Generate manifests.
1921
if [[ -f "tools/generate-ai-manifest.py" ]]; then
20-
echo "📄 Generating directory manifests..."
22+
echo "[ai-bootstrap] Generating directory manifests..."
2123
python3 tools/generate-ai-manifest.py
2224
else
23-
echo "⚠️ Warning: tools/generate-ai-manifest.py not found."
25+
echo "[ai-bootstrap] WARN: tools/generate-ai-manifest.py not found"
2426
fi
2527

26-
# 2. Sync Wiki Documentation
28+
# 2. Sync Wiki documentation.
2729
if [[ -f "tools/sync-wiki.py" ]]; then
28-
echo "📖 Syncing Wiki..."
30+
echo "[ai-bootstrap] Syncing Wiki..."
2931
python3 tools/sync-wiki.py
3032
else
31-
echo "⚠️ Warning: tools/sync-wiki.py not found."
33+
echo "[ai-bootstrap] WARN: tools/sync-wiki.py not found"
3234
fi
3335

34-
# 3. Generate Unified Knowledge Base (RAG Snapshot)
36+
# 3. Generate unified knowledge base (RAG snapshot).
3537
if [[ -f "tools/generate-unified-knowledge.py" ]]; then
36-
echo "🧠 Generating Unified Knowledge Base (RAG Snapshot)..."
37-
if [[ -f "tools/journal-sync.py" ]]; then
38-
python3 tools/journal-sync.py
39-
fi
38+
echo "[ai-bootstrap] Generating unified knowledge base (RAG snapshot)..."
39+
[[ -f "tools/journal-sync.py" ]] && python3 tools/journal-sync.py
4040
python3 tools/generate-unified-knowledge.py
4141
else
42-
echo "⚠️ Warning: tools/generate-unified-knowledge.py not found."
42+
echo "[ai-bootstrap] WARN: tools/generate-unified-knowledge.py not found"
4343
fi
4444

45-
# 4. Initialize agents/research
45+
# 4. Initialize agents/research scratchpad if present.
4646
if [[ -d "agents/research" ]]; then
47-
echo "🧪 Initializing agents/research (Agent Starter Pack)..."
48-
# Placeholder for future agent initialization logic
49-
# (cd agents/research && make install)
47+
echo "[ai-bootstrap] Initializing agents/research scratchpad..."
5048
else
51-
echo "⚠️ Warning: agents/research directory not found."
49+
echo "[ai-bootstrap] WARN: agents/research directory not found"
5250
fi
5351

54-
# 3. Persistence: Refresh environment configs and dotfiles
55-
echo "💾 Persisting environment state..."
52+
# 5. Refresh environment configs and dotfiles.
53+
echo "[ai-bootstrap] Persisting environment state..."
5654
if [[ -f "tools/refresh-env.py" ]]; then
5755
python3 tools/refresh-env.py
5856
else
59-
echo "⚠️ Warning: tools/refresh-env.py not found."
57+
echo "[ai-bootstrap] WARN: tools/refresh-env.py not found"
6058
fi
6159

62-
echo " Workspace initialization complete."
60+
echo "[ai-bootstrap] Workspace initialization complete."
6361

64-
# 6. Seed Artifacts for Agents
65-
echo "🌱 Seeding latest MiOS Artifacts for initialized agents..."
62+
# 6. Seed RAG context for downstream agents.
63+
echo "[ai-bootstrap] Seeding latest MiOS context for initialized agents..."
6664
if [[ -f "artifacts/repo-rag-snapshot.json.gz" ]]; then
67-
# Shared scratchpad for cross-agent IPC
6865
mkdir -p .ai/foundation/shared-tmp/
6966
cp artifacts/repo-rag-snapshot.json.gz .ai/foundation/shared-tmp/latest-context.json.gz
70-
# Sub-project local context
7167
cp artifacts/repo-rag-snapshot.json.gz agents/research/latest-context.json.gz
72-
echo " Context seeded to .ai/foundation/shared-tmp/ and agents/research/"
68+
echo "[ai-bootstrap] Context seeded to .ai/foundation/shared-tmp/ and agents/research/"
7369
else
74-
echo "⚠️ Warning: artifacts/repo-rag-snapshot.json.gz not found. Skip seeding."
70+
echo "[ai-bootstrap] WARN: artifacts/repo-rag-snapshot.json.gz not found; skipping seed"
7571
fi

0 commit comments

Comments
 (0)