Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/skills/self-improvement/SKILL.md # aien-sovereign-core-mv AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / skills / self-improvement / SKILL.md` 115 lines ยท 7538 bytes Raw Blame History Rendered 1 --- 2 name: self-improvement 3 description: Autonomous self-improvement protocol for AIEN: isolated git worktree sandboxing, Microsoft SkillOpt optimization, JSpace dynamic dream cycles, and headless browser mirror self-testing via Chrome DevTools Protocol. 4 --- 5 6 # Autonomous Self-Improvement and Browser Mirror Protocol 7 8 Use this skill when modifying AIEN core code, improving skills via Microsoft SkillOpt, inspecting the JSpace dream cycle, or verifying live UI and streaming behavior using the headless browser mirror harness. 9 10 ## Core Pillars of Sovereign Self-Improvement 11 12 1. Never Break Live Harnesses: 13 Live systemd services (spark-cockpit.service, ~/.local/bin/aien) must never be edited directly. All exploratory code modifications, refactorings, and experiments must take place inside an isolated git worktree sandbox. 14 2. Deterministic IPC over Flaky Webhooks: 15 Browser self-testing uses Chrome DevTools Protocol (CDP) WebSocket on port 9222 and local Unix Domain Sockets (UDS). Webhooks are strictly forbidden for local control loops. 16 3. Dual-Seat Mirror Auditing: 17 AIEN tests his live Cockpit UI by driving headless Chrome as an adversarial auditor, verifying page hydration, live token streaming via Axum SSE, tactile action buttons, and tab transitions. 18 19 ## 1. The Autonomous Sandbox Subsystem (aien --sandbox) 20 21 When tasked with improving or modifying your own codebase (aien-sovereign-core): 22 23 ### Step 1: Initialize the Worktree Sandbox 24 Run the sandbox init command to branch main into an isolated worktree at ~/workspace/aien-sandbox: 25 ```bash 26 aien --sandbox init auto-improve 27 ``` 28 Or directly via git: 29 ```bash 30 git -C ~/workspace/aien-sovereign-core worktree add ~/workspace/aien-sandbox -b auto-improve 31 ``` 32 33 ### Step 2: Make Edits and Run Tests 34 Apply edits inside ~/workspace/aien-sandbox. 35 Verify compiler checks and test passes: 36 ```bash 37 aien --sandbox test 38 ``` 39 Or directly: 40 ```bash 41 cargo check --tests --manifest-path ~/workspace/aien-sandbox/Cargo.toml 42 ``` 43 44 ### Step 3: Inspect Sandbox Status 45 Check git diff and untracked changes within the worktree: 46 ```bash 47 aien --sandbox status 48 ``` 49 50 ### Step 4: Promote Verified Edits or Clean Up 51 If tests pass, promote the branch into main and rebuild the release binary: 52 ```bash 53 aien --sandbox promote "feat(core): verified autonomous self-improvement" 54 ``` 55 If tests fail or the experiment is aborted, clean the worktree: 56 ```bash 57 aien --sandbox clean 58 ``` 59 60 ## 2. Microsoft SkillOpt Self-Evolution Loop 61 62 To optimize a sovereign skill against a held-out benchmark split using the local model seat on port 18006: 63 64 ```bash 65 bash ~/atlas-skillopt-stage.sh 66 ``` 67 68 ### Key Operational Invariants 69 1. Endpoint and Model: 70 The local model seat on port 18006 registers as atlas-lightning-omni. Both OPTIMIZER_DEPLOYMENT and TARGET_DEPLOYMENT must be set to atlas-lightning-omni. 71 2. Split Size Alignment: 72 When running mini-batch iterations, pass --limit N matching train.train_size=N to satisfy dataloader size assertions. 73 3. Worker Throttling: 74 Set env.workers to 2 and env.exec_timeout to 300 in the dataset YAML configuration to avoid saturating the model seat batch queue. 75 4. Output Artifacts: 76 Produces best_skill.md and automatically deploys the winning patch to ~/skills/atlas-skillopt/SKILL.md. 77 78 ## 3. JSpace Dynamic Dream Cycle (Eden Loop) 79 80 The autonomous consolidation loop operates continuously in the background on port 18085 during operator idle windows. 81 82 ### Status and Health Probing 83 ```bash 84 curl -s http://127.0.0.1:18085/health 85 curl -s http://127.0.0.1:18085/pulse 86 ``` 87 Outputs heartbeat BPM, coherence score, secret hygiene posture, and territory maps. 88 89 ### Manual Cycle Trigger and Integration Verification 90 The Python dream engine (basecamp/aien-dream/dream_engine.py) was removed from the sovereign build (sovereign-core #181). The `/dream` command in `aien` now says so and points to the native `spark-dream` binary for dream telemetry. A manual cycle trigger and the scoring/storage verification are unavailable until a native replacement lands. 91 92 ## 4. Headless Browser Mirror and Mentor Harness 93 94 AIEN drives a headless Chrome over the Chrome DevTools Protocol from Rust (`crates/aien-cli/src/browser_mirror.rs`, sovereign-core #180). No Python and no extra crates: the websocket client and the base64 decoder live in the module. The same code runs behind the `browser` tool, `aien --browser`, and the standalone binary: 95 96 ``` 97 aien-browser-mirror --test # Cockpit self-test: report.json + 3 screenshots 98 aien-browser-mirror --mentor "" # one chat prompt, waits for the reply, screenshot 99 aien-browser-mirror --screenshot [file.png] --url U # screenshot of any page 100 aien-browser-mirror --eval "" --url U # evaluate an expression on any page 101 ``` 102 103 Defaults: `--url http://127.0.0.1:18095` (override with `--url` or `AIEN_COCKPIT_URL`), `--out-dir ~/basecamp/ui-tests`, Chrome found as `google-chrome`, `chromium` or `AIEN_CHROME`. Exit status 0 means PASSED, COMPLETED or ok. 104 105 On Linux with pidfd support, each run starts Chrome with an `AIEN_BROWSER_MIRROR_TAG` environment tag and leaves it in the caller's process group, so a Ctrl-C or a harness group kill that ends the caller also reaches Chrome. Linux cleanup uses only pidfd signaling, never numeric PID or process-group signals. After pinning each candidate, it revalidates an exact environment tag or private-profile argument. Chrome clears tags and rewrites argv on some tasks, so a rewritten title requires a Chrome image (`chrome`, `chromium` or `chromium-browser`), its exact executable prefix and a complete profile flag, not a substring or prefix match. Profiles are created exclusively with mode 0700. Tags and profile arguments distinguish these owned fixtures; they are not an authentication boundary against same-UID processes deliberately copying them. A cleanup timeout emits a diagnostic and retains the private profile rather than blocking indefinitely or deleting potentially active browser data. Unsupported Linux pidfd signaling refuses the spawn. On other Unix platforms Chrome leads its own process group and cleanup signals that group; detached-helper cleanup there is not qualified. Chrome runs with `--disable-gpu --use-gl=disabled --disable-software-rasterizer`: without the last two flags, Chrome 153 on aarch64 falls back to a SwiftShader GPU process that never answers a screenshot (sovereign-core #661). 106 107 The self-test checks hydration (title, `#chat-input`, navigation controls), a live chat reply sent through `#btn-send` that stops growing, and every `[data-view]` or `[data-tab]` control switching to a present view. Screenshots land as `cockpit_init.png`, `cockpit_chat_stream.png` and `cockpit_actions.png`, next to `report.json`. The mentor run writes `cockpit_mentor_response.png` and `mentor_response.json` (COMPLETED when the reply is longer than 50 characters). The Cockpit must be running for the self-test; against a dead port the report says FAILED with `chat_input: false`. 108 109 ## 5. Cortex Memory Commitment 110 111 Record a durable procedure receipt to Spark Cortex from inside `aien`, using the built-in command (name, a vertical bar, then the content): 112 ``` 113 /cortex write sovereign_self_improvement_loop | Verified self-improvement procedure: isolated git worktree in ~/workspace/aien-sandbox, JSpace dream telemetry via spark-dream, and Microsoft SkillOpt validation gate. 114 ``` 115 The command reads CORTEX_TOKEN from the AIEN vault and prints the receipt id; check it with `/cortex search sovereign_self_improvement_loop`.