newOS4 Roadmap

Self-Improving Autonomous OS โ€” Pipeline Review & Implementation Plan
v4.6.03 LIVE v4.6.09 SHIPPED v4.6.10 PLANNED
9/9 Tools Live 7/7 Phases (6 shipped, 1 planned) Auto-Commit Active

๐Ÿ“‹ Executive Summary

The self-improvement pipeline is live at v4.6.09 with a 7-step loop: edit โ†’ test โ†’ health โ†’ regression โ†’ score โ†’ auto-commit (โ‰ฅ70) โ†’ verify โ†’ learn. All 6 original phases shipped. Phase 7 (v4.6.10) adds a DebugSupervisorModule โ€” persistent error database, clustering, root-cause analysis, and cross-session auto-fix learning.

โœ… Current State โ€” What's Live (v4.6.09)

Pipeline Architecture (verified in browser)

ship_module({name, code, tests, commit:true})
  โ”‚
  โ”œโ”€ 1. WRITE    โ†’ _mods/Module.js + meta.json
  โ”œโ”€ 2. TEST     โ†’ test_module(name, tests)
  โ”‚     โ”œโ”€ Load from _mods/ via loadModuleFromCode()
  โ”‚     โ”œโ”€ JS error capture โ† LIVE
  โ”‚     โ”œโ”€ Check: module loaded OK? โ†’ rollback if not
  โ”‚     โ”œโ”€ Check: commands lost? โ†’ rollback if yes
  โ”‚     โ”œโ”€ Run test assertions [{command, expect}] โ†’ rollback on fail
  โ”‚     โ””โ”€ Smoke test: run first command โ†’ rollback on fail
  โ”œโ”€ 3. HEALTH   โ†’ health_check()
  โ”‚     โ”œโ”€ Core commands: ls, pwd, echo, help, grep, find, tree, cat
  โ”‚     โ”œโ”€ JS error capture โ† LIVE
  โ”‚     โ”œโ”€ Module count
  โ”‚     โ”œโ”€ World model version match
  โ”‚     โ””โ”€ Agent status (total/healthy/failed)
  โ”œโ”€ 4. REGRESS  โ†’ _runRegressionSuite(moduleName)
  โ”‚     โ””โ”€ 30+ tests across all modules โ† LIVE
  โ”œโ”€ 5. SCORE    โ†’ _calculateConfidence()
  โ”‚     โ””โ”€ score โ‰ฅ 70 โ†’ auto-approve
  โ”‚     โ””โ”€ score < 70 โ†’ human approval required
  โ”œโ”€ 6. COMMIT   โ†’ _executeCommit()
  โ”‚     โ”œโ”€ WebDAV push standalone .js
  โ”‚     โ”œโ”€ Bundle sync (find class block, replace)
  โ”‚     โ”œโ”€ Version bump (main.html + module-loader.js)
  โ”‚     โ”œโ”€ Post-commit syntax check โ† LIVE
  โ”‚     โ””โ”€ Auto-revert on syntax error โ† LIVE
  โ”œโ”€ 7. VERIFY   โ†’ Post-commit fetch + validate โ† LIVE
  โ””โ”€ 8. LEARN    โ†’ _postRunReview + skill creation
        โ””โ”€ Auto-fix suggestions โ† LIVE

Tools Verified Live

ToolStatusNotes
edit_moduleโœ… LiveWrites to _mods/, auto-loads
test_moduleโœ… LiveHas assertions + inline rollback
reload_moduleโœ… LiveReverts _mods/, reloads from URL
list_modified_modulesโœ… LiveLists pending edits
health_checkโœ… LiveCore cmds + world model + agents
diff_moduleโœ… LiveLine-by-line diff, orig vs new
ship_moduleโœ… LiveFull pipeline orchestrator with auto-commit (score โ‰ฅ 70)
commit_moduleโœ… LiveAuto-executes if confidence โ‰ฅ 70, else creates pending commit
run_commandโœ… LiveCaptures output via print monkey-patch

Terminal Commands (human-facing)

CommandStatusNotes
commit-approveโœ… LiveExecutes pending commit (WebDAV + bundle + version)
commit-denyโœ… LiveCancels pending commit
commit-statusโœ… LiveShows pending commit details

๐Ÿ” Gap Analysis โ€” What's Missing for Full Autonomy

GAP 1 โ€” P0 SAFETY CRITICAL
No JS Error Capture โ€” _captureConsoleErrors() never coded
The health_check handler sets results.healthy = allCoreOk && results.versionMatch โ€” it does NOT check for JavaScript errors. A module edit that introduces a silent TypeError in a method that isn't called by the 4 core commands will pass health_check and proceed to commit.
Impact: AI can commit a module that throws errors on grep, find, tree without detection.
Fix: Implement _captureConsoleErrors(durationMs) using console.error + window.onerror interception. Wire into both test_module (after load) and health_check (add to results.healthy check).
GAP 2 โ€” P0 COVERAGE CRITICAL
Regression Suite Too Thin โ€” 15/19 modules have zero tests
ModuleTestsModuleTests
ShellModule4WebDAVModule0
SystemModule2CronModule0
OrchestratorModule1ThemeModule0
WebX11AIAssistantModule1MindmapModule0
+ 11 more untestedCalcModule, MediaModule, VoiceModule, etc.
Impact: AI edits any of 15 untested modules โ†’ regression returns {allPassed: true, total: 0} โ€” a false positive. Pipeline commits without verification.
Fix: Add 2+ regression tests per module to _regressionTasks(). Data-only change โ€” the array just needs more entries. Target: 30+ tests across all 19 modules.
GAP 3 โ€” P1 SAFETY NET
No Post-Commit Verification
After commit-approve pushes files via WebDAV, there's no verification that the committed code actually works on a fresh page load. If the code has a syntax error that passes loadModuleFromCode but fails at HTTP fetch time, the next user refresh breaks the system.
Fix: After WebDAV push, fetch the file via HTTP, validate with new Function(code) (browser-safe syntax check). If validation fails, auto-revert by re-uploading the original code.
GAP 4 โ€” P1 DECISION GATE
No Confidence Score
The pipeline is binary โ€” all tests pass โ†’ commit, any test fails โ†’ rollback. A 1-line typo fix in CalcModule (no regression tests) is treated the same as a 200-line rewrite of ShellModule (4 regression tests). Both get commit: true.
Fix: _calculateConfidence(modName, testResult, healthResult, regResult, changeCount). Penalize: large changes, no regression tests, critical modules. Bonus: comprehensive AI-written tests. Auto-approve at โ‰ฅ 70.
GAP 5 โ€” P1 RECOVERY
No Automatic Rollback on Next-Boot Failure
If a committed change breaks the system on next page load, there's no automatic recovery. The user has to manually identify the broken module and revert it.
Fix: Add a "boot watchdog" โ€” before commit, save version to last-good-version.json. On boot, if core modules fail to register within timeout, auto-fetch and restore last-good versions.
GAP 6 โ€” P2 AUTONOMY
Self-Improvement Trigger Not Implemented (Phase G)
The plan's Phase G called for extending _postRunReview to detect repeated tool failures and suggest edit_module fixes. This was never coded. The AI doesn't autonomously identify bugs to fix โ€” it only uses the pipeline when told to.
Fix: Build _toolToModuleMap at init. Extend _postRunReview to detect repeated tool failures โ†’ push auto-fix suggestions into next AI turn's context.

๐Ÿšฆ The Confidence Gate (Replaces Human Gate)

Instead of a binary human-approve/deny, the system calculates a confidence score based on test coverage, change size, and module criticality. High-confidence changes auto-commit; low-confidence changes still require human approval.

โ‰ฅ 85 Auto-commit
immediately
70โ€“84 Auto-commit
with log
50โ€“69 Human approval
required
< 50 Auto-abort

Scoring Formula

Starting score: 100

Penalties:
  Change > 50 lines:          -20
  Change > 100 lines:         -20 (additional)
  No regression tests:        -30
  Critical module:            -15  (ShellModule, SystemModule, OrchestratorModule, AIAssistant)
  JS errors detected:         -50

Bonuses:
  3+ AI-written tests:        +10

Final score = max(0, min(100, score))

๐Ÿ—๏ธ Target Architecture: v4.6.10 (Full Autonomy)

ship_module({name, code, tests, commit:true})
  โ”‚
  โ”œโ”€ 1. WRITE    โ†’ _mods/Module.js
  โ”œโ”€ 2. TEST     โ†’ test_module(name, tests)
  โ”‚     โ”œโ”€ Load + JS error capture โ† NEW
  โ”‚     โ”œโ”€ Command count check
  โ”‚     โ”œโ”€ Test assertions
  โ”‚     โ””โ”€ Smoke test
  โ”œโ”€ 3. HEALTH   โ†’ health_check()
  โ”‚     โ”œโ”€ Core commands (expanded to 8 โ† NEW)
  โ”‚     โ”œโ”€ JS error capture โ† NEW
  โ”‚     โ”œโ”€ Module count
  โ”‚     โ”œโ”€ World model version
  โ”‚     โ””โ”€ Agent status
  โ”œโ”€ 4. REGRESS  โ†’ _runRegressionSuite(moduleName)
  โ”‚     โ””โ”€ 30+ tests across all modules โ† EXPANDED
  โ”œโ”€ 5. SCORE    โ†’ _calculateConfidence() โ† NEW
  โ”‚     โ””โ”€ score โ‰ฅ 70 โ†’ auto-approve
  โ”‚     โ””โ”€ score < 70 โ†’ human approval required
  โ”œโ”€ 6. COMMIT   โ†’ _executeCommit() (auto if score โ‰ฅ 70 โ† NEW)
  โ”‚     โ”œโ”€ WebDAV push
  โ”‚     โ”œโ”€ Bundle sync
  โ”‚     โ”œโ”€ Version bump
  โ”‚     โ”œโ”€ Post-commit syntax check โ† NEW
  โ”‚     โ””โ”€ Auto-revert on syntax error โ† NEW
  โ”œโ”€ 7. VERIFY   โ†’ Post-commit fetch + validate โ† NEW
  โ””โ”€ 8. LEARN    โ†’ _postRunReview + skill creation
        โ””โ”€ Auto-fix suggestions โ† NEW

๐Ÿ“… Implementation Phases

PHASE 1 โœ… v4.6.03 SHIPPED ~1.5h
Safety Nets โ€” JS Error Capture
PHASE 2 โœ… v4.6.04 SHIPPED ~2h
Regression Coverage โ€” 30+ Tests
PHASE 3 โœ… v4.6.05 SHIPPED ~1.5h
Post-Commit Verification + Auto-Revert
PHASE 4 โœ… v4.6.06 SHIPPED ~2h
Confidence Gate + Auto-Approve
PHASE 5 โœ… v4.6.08 SHIPPED ~1.5h
Self-Improvement Trigger โ€” Autonomous Bug Detection
PHASE 6 โœ… v4.6.09 SHIPPED ~2.5h
Boot Watchdog โ€” Recovery on Failed Boot
PHASE 7 ๐Ÿ”ถ v4.6.10 PLANNED ~4h
DebugSupervisorModule โ€” Persistent Error DB + Clustering + Auto-Fix

๐Ÿงช Testing Strategy โ€” How to Validate Without Human Interaction

The Bootstrapping Problem

To test autonomous self-improvement without human interaction, we need to verify the system can: detect a bug, fix it, test the fix, commit without asking a human, verify the commit didn't break anything, and recover if it did.

Test Scenarios

IDScenarioExpected BehaviorVerification
T1 AI fixes a typo in CalcModule (1 line, non-critical) Confidence โ‰ฅ 85, auto-commit, post-commit syntax check passes Check commit-log.json for autoApproved: true
T2 AI tries to rewrite ShellModule (100+ lines, critical) Confidence < 70, requires human approval Pipeline output: confidence: <70, humanApprovalRequired: true
T3 AI edits a module with a TypeError in a method test_module catches JS error, auto-rollback test_module output: errors: [...]
T4 AI commits code with syntax error that passes loadModuleFromCode Auto-revert fires, original code restored Commit log: reverted: true, syntaxError: ...
T5 AI edits MindmapModule (0 regression tests) Confidence reduced by 30, likely requires human approval Check confidence score
T6 Manually break a module file on server, refresh page Boot watchdog detects failure, reverts to last-good Console: "Boot watchdog: reverting..."
T7 Trigger repeated run_command failures in a session _postRunReview suggests ship_module for broken module Check next AI turn for auto-fix suggestion
T8 Tell AI "the calc command is broken, fix it" Full autonomous cycle: edit โ†’ test โ†’ health โ†’ regress โ†’ score โ†’ auto-commit โ†’ verify Check commit log + server file + page refresh

Validation Procedure

1. Open main.html in browser
2. Via browser_console, inject a known bug:
   ai.terminal.fs.writeFile('_mods/CalcModule.js', buggyCode)
3. Tell the AI: "The calc command returns wrong results. Fix it."
4. AI should:
   a. Read the current CalcModule source
   b. Identify the bug
   c. Call ship_module({name:'CalcModule', code: fixedCode, tests:[{command:'calc 1+1', expect:'2'}], commit:true})
   d. Pipeline runs: test โ†’ health โ†’ regression โ†’ score
   e. If score โ‰ฅ 70: auto-commit, post-commit verify
   f. If score < 70: print "Human approval required, type commit-approve"
5. Verify:
   - Commit log has entry
   - Server file updated (curl the .js URL)
   - Page refresh loads new version
   - calc 1+1 returns 2

โš ๏ธ Risks & Mitigations

RiskSeverityMitigation
AI commits broken code that passes tests High Confidence score penalizes thin coverage; post-commit syntax check; boot watchdog
Bundle sync corrupts core-bundle.js High new Function() validation before upload; auto-revert; git backup
AI enters infinite fix loop Medium Rate limit (5 commits/day); cooldown (10 min); max 3 retries per module per session
Auto-fix suggestions pollute AI context Low Cap suggestions at 3 per session; clear after each agentic loop
Boot watchdog false positive Medium Only trigger if module count < 50% of expected; require 2 consecutive failed boots
Confidence threshold too permissive Medium Start at 70, tune based on commit success rate; log all auto-commits for review
WebDAV token lacks write scope Low Already verified working in v4.6.02 (TTS/SST changes were committed)

๐Ÿ”ฌ Key Issues Found During Live Audit

#IssueLocationEvidence
1 _captureConsoleErrors undefined โ€” planned but never coded module-aiassist.js typeof ai._captureConsoleErrors === 'undefined'
2 _rollbackModule and _runTestAssertion not implemented as planned module-aiassist.js Both undefined; rollback is inline, not reusable
3 Health check doesn't check JS errors health_check handler results.healthy = allCoreOk && versionMatch โ€” no jsErrors check
4 Regression suite returns false positive for untested modules _runRegressionSuite total: 0 โ†’ allPassed: true โ€” passes by default
5 ship_module with commit:true still creates pending commit (doesn't auto-execute) ship_module handler Calls commit_module โ†’ stores _pendingCommit โ€” human gate always active
6 No _toolToModuleMap โ€” Phase G can't map failures to modules module-aiassist.js No mapping between AI tool names and source modules

๐Ÿ“ Files Likely to Change

FileChangesPhase
module-aiassist.js _captureConsoleErrors, expanded _regressionTasks, _calculateConfidence, post-commit verify, _postRunReview extension, _toolToModuleMap 1โ€“5
core-bundle.js Sync all changes from module-aiassist.js 1โ€“5
main.html Boot watchdog script, version bump 6
module-loader.js Version bump 6

โ“ Open Questions

Q1: Confidence threshold starting point โ€” 70 is my recommendation. Higher (80, more conservative) or lower (60, more permissive)? Can be tuned after observing auto-commit success rates.
Q2: Boot watchdog scope โ€” auto-revert ANY failed boot, or only boots that fail within N seconds of a recent commit? A blanket auto-revert could undo intentional architecture changes.
Q3: Auto-fix suggestion delivery โ€” inject into AI's system prompt (passive, safer) or auto-prompt the AI to fix them (active, risks runaway fix loops)?
Q4: Should commit:true in ship_module bypass the confidence gate? Options: (a) auto-commit if score โ‰ฅ threshold, (b) always human gate, (c) separate auto:true flag.