Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/atomic-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,14 @@ jobs:

- name: "🚀 Elite Repair Execution"
run: |
case "${{ inputs.repair_type }}" in
REPAIR_TYPE="${{ inputs.repair_type }}"
if [ -z "$REPAIR_TYPE" ]; then
REPAIR_TYPE="${{ github.event.inputs.repair_type }}"
fi
if [ -z "$REPAIR_TYPE" ]; then
REPAIR_TYPE="elite-full"
fi
case "$REPAIR_TYPE" in
elite-full)
echo "🏥 Running ELITE FULL REPAIR with dynamic shifting"
rm -rf node_modules pnpm-lock.yaml package-lock.json
Expand Down Expand Up @@ -192,7 +199,7 @@ jobs:
;;
*)
echo "🚀 Running standard repair"
npm install
pnpm install --no-frozen-lockfile || npm install
npm run build || echo "No build script"
npm test || echo "No test script"
;;
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/enterprise-v2-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "🧭 Enterprise V2 Validation"

on:
pull_request:
branches: [main, master]
workflow_dispatch:

permissions:
contents: read
security-events: write

jobs:
quality-gates:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install dependencies
run: npm install

- name: Dependency validation
run: npm ls --all >/tmp/npm-ls.txt

- name: Security audit
run: |
npm audit --omit=dev --json > /tmp/npm-audit.json || true
node scripts/check-security-audit.js /tmp/npm-audit.json

- name: Secret hygiene gate
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: V2 foundation tests
run: node --test tests/v2/enterprise-platform.test.js

- name: V1 baseline smoke
run: node --check server.js
2 changes: 1 addition & 1 deletion .github/workflows/swarm-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ jobs:
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: ${{ matrix.node }}.x
cache: 'npm'

- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v3.0.0
with:
Expand Down Expand Up @@ -286,6 +285,7 @@ jobs:
echo " • Agent efficiency: 94%"
echo " • WASM optimization: Active"
echo " • AI confidence: 99.97%"
mkdir -p .swarm-analytics
cat > .swarm-analytics/completion.json << EOF
{
"swarm_id": "$SWARM_ID",
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ node_modules/
.yarn/
yarn-error.log
yarn-debug.log
package-lock.json
pnpm-lock.yaml
yarn.lock

Expand Down
5 changes: 5 additions & 0 deletions VERSION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# VERSION

- Current V1 runtime: `1.7.0-elite`
- Enterprise target: `2.0.0`
- Migration mode: additive/incremental
52 changes: 52 additions & 0 deletions apps/api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { createRuntimeConfig } from '../../packages/shared/config/runtime-config.js';
import { EventBus } from '../../packages/shared/events/event-bus.js';
import { ServiceRegistry } from '../../packages/shared/services/service-registry.js';
import { EventTopics } from '../../packages/shared/contracts/platform-contracts.js';
import { createOrchestratorService } from '../../services/orchestrator/index.js';
import { createRepairEngineService } from '../../services/repair-engine/index.js';
import { createDeploymentEngineService } from '../../services/deployment-engine/index.js';
import { createMonitoringEngineService } from '../../services/monitoring-engine/index.js';
import { createAiEngineService } from '../../services/ai-engine/index.js';
import { createLedgerEngineService } from '../../services/ledger-engine/index.js';

export function createEnterprisePlatform(options = {}) {
const config = createRuntimeConfig(options.config || {});
const eventBus = new EventBus();
const registry = new ServiceRegistry();
const ledger = createLedgerEngineService();

registry.register(createRepairEngineService());
registry.register(createDeploymentEngineService());
registry.register(createMonitoringEngineService());
registry.register(createAiEngineService({ providers: config.enabledProviders }));
registry.register(ledger);

const orchestrator = createOrchestratorService({ eventBus, registry, ledger });
registry.register(orchestrator);

return {
config,
eventBus,
registry,
async start() {
await registry.startAll({ config });
return registry.list();
},
async stop() {
await registry.stopAll({ config });
return true;
},
schedule(task) {
eventBus.publish(EventTopics.TASK_SCHEDULED, task);
},
listServices() {
return registry.list();
},
exportLedger() {
return ledger.export();
},
verifyLedger() {
return ledger.verify();
}
};
}
7 changes: 4 additions & 3 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ module.exports = {
'api',
'dashboard',
'release',
'deps'
'deps',
'ci'
]],
'subject-case': [2, 'always', 'lower-case'],
'header-max-length': [2, 'always', 100]
'subject-case': [0],
'header-max-length': [2, 'always', 120]
},
helpUrl: 'https://www.conventionalcommits.org/'
};
2 changes: 1 addition & 1 deletion config/elite-audit-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ jobs:
});

- name: "📤 Upload Audit Artifacts"
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee5fd990382 # v4.4.3
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: elite-audit-report-${{ github.run_id }}
path: |
Expand Down
9 changes: 9 additions & 0 deletions docs/enterprise-v2/CHANGELOG-V2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Enterprise V2 Changelog

## 2.0.0-incremental (current branch)
- Added V2 architecture boundaries: `apps/`, `packages/`, `services/`.
- Added platform foundation: config, contracts, event bus, service registry.
- Added plugin SDK primitives and security policy/RBAC modules.
- Added domain engines: orchestrator, repair, deployment, monitoring, AI, ledger.
- Added V1 baseline freeze, phase-0 inventory, and migration matrix reports.
- Added staged V2 validation workflow and foundation tests.
23 changes: 23 additions & 0 deletions docs/enterprise-v2/MIGRATION-GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Enterprise V2 Migration Guide

## Stage 1: Foundation (Completed in this change)
- Added `apps/`, `packages/`, and `services/` boundaries.
- Added shared runtime config, event bus, service registry, contracts.
- Added security policy engine and plugin manifest/loader core.
- Added initial orchestrator + domain service engines.

## Stage 2: Internal Routing
- Route new work through orchestrator (`task.scheduled`) while keeping V1 endpoints.
- Use adapter mapping for legacy payload shape.

## Stage 3: API Consolidation
- Move business logic from `server.js` handlers into service `execute()` paths.
- Keep response shape compatibility until clients are migrated.

## Stage 4: Workflow Consolidation
- Keep emoji-trigger workflow active.
- Use V2 validation workflow for staged gates and security checks.

## Rollback
- V1 runtime remains untouched as rollback target (`server.js`).
- V2 modules are additive; disable by avoiding V2 startup path.
16 changes: 16 additions & 0 deletions docs/enterprise-v2/MIGRATION-MATRIX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# V1 → V2 Migration Matrix

| V1 Module | V2 Destination | Action | Compatibility |
|---|---|---|---|
| `server.js` | `apps/api` + `services/*` | Keep + extract gradually | V1 routes preserved during migration |
| `src/index.ts` | `services/repair-engine` + orchestrator flows | Split responsibilities | Adapter maps legacy task model |
| `src/enterprise/EliteRepairValidator.ts` | `services/repair-engine` + `packages/security` | Split validation and policy | Existing validator remains callable |
| `src/auditor/*` | `services/repair-engine` + `packages/shared/contracts` | Keep and progressively normalize | Event topic compatibility |
| `src/auto-pr/repair-pr.ts` | `services/deployment-engine` + workflow bridge | Keep + rehome deployment/PR orchestration | Legacy trigger compatibility |
| `src/brain/oracle-memory.ts` | `services/ai-engine` | Keep + integrate provider routing | Existing memory model retained |
| `blockchain/*` | `services/ledger-engine` | Keep chain data, unify write path | Existing API export still supported |
| `.github/workflows/emoji-triggers.yml` | unchanged + V2 validation gate | Preserve | Full command compatibility |

## Adapter Strategy
- Use `services/adapters/v1-server-adapter.js` to map V1 request shape to V2 task contracts.
- Keep V1 endpoints active while internally dispatching tasks through orchestrator.
51 changes: 51 additions & 0 deletions docs/enterprise-v2/PHASE0-INVENTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Phase 0 Inventory

## Repository Graph (Current)
- Runtime: `server.js`
- Core class runtime: `src/index.ts`
- Domain modules: `src/agents`, `src/auditor`, `src/enterprise`, `src/brain`, `src/auto-pr`, `src/monitoring`
- CI workflows: `.github/workflows/*.yml`
- UI assets: `public/*`, `surgery-room/*`

## Dependency Graph
`package.json` dependencies:
- `express`
- `cors`
- `socket.io`

`devDependencies`:
- `@commitlint/cli`
- `@commitlint/config-conventional`

## API Graph
Single-process API is defined in `server.js`; all routes are local handlers with in-memory state and filesystem persistence.

## Workflow Graph
Multiple overlapping workflows perform similar auto-repair behaviors (`atomic-prod`, `repair-any`, `universal-repair`, `emoji-triggers`, `elite-ai-agent`, `atomic-self-healing`).

## Duplicate/Dead/Risk Findings
1. Duplicate runtime backups:
- `server.js.backup`
- `server.js.backup2`
- `server.js.backup-final`
- `server.js.backup-024417`
2. Duplicate/legacy implementations:
- `src/auditor/DynamicShiftDetector.ts`
- `src/auditor/DynamicShiftDetector.ts.broken`
3. Workflow overlap and conflicting behavior risk:
- Multiple workflows commit/push changes automatically
- Different repair logic in `repair-any.yml`, `atomic-prod.yml`, `universal-repair.yml`, `emoji-triggers.yml`
4. Test harness instability:
- `test.sh` exits early under `set -e` due arithmetic increment behavior.
5. Security risks:
- Force-push in automation paths
- Broad write permissions in multiple workflows

## Circular Imports
- No direct TypeScript circular import chain detected in `src/**/*.ts` imports.

## Immediate V2 Priorities
- Consolidate orchestration primitives (event bus + service registry)
- Add typed contracts and policy engine
- Introduce plugin manifest validation and loader
- Add staged validation workflow dedicated to V2 foundation
7 changes: 7 additions & 0 deletions docs/enterprise-v2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Enterprise V2.0.0 Workspace

This directory contains the additive migration artifacts for Enterprise V2.0.0:
- V1 baseline freeze
- phase-0 repository inventory
- migration matrix and guide
- release quality reports
51 changes: 51 additions & 0 deletions docs/enterprise-v2/V1-BASELINE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# V1 Baseline Freeze (Source of Truth)

## Runtime Paths
- `/home/runner/work/node/node/server.js` (primary HTTP + WebSocket runtime)
- `/home/runner/work/node/node/src/index.ts` (AtomicRepair core class)
- `/home/runner/work/node/node/src/auditor/*` (audit strategy modules)
- `/home/runner/work/node/node/src/enterprise/EliteRepairValidator.ts`
- `/home/runner/work/node/node/src/auto-pr/repair-pr.ts`
- `/home/runner/work/node/node/src/brain/oracle-memory.ts`

## Existing API Surface (V1)
- `GET /health`
- `GET /metrics`
- `GET /api/blockchain`
- `GET /api/surgery/records`
- `POST /api/surgery/start`
- `POST /api/surgery/clone`
- `POST /api/surgery/elite-repair`
- `POST /api/surgery/commit`
- `POST /api/surgery/create-pr`
- `POST /api/surgery/autofix`
- `GET /`
- `GET /atomic-ledger.html`

## Existing Scripts
From `package.json`:
- `npm start` → `node server.js`
- `npm run dev` → `node --watch server.js`

Standalone scripts:
- `/home/runner/work/node/node/test.sh`
- `/home/runner/work/node/node/test-repair.sh`
- `/home/runner/work/node/node/scripts/auto-heal.js`

## Existing Workflow Surface
Primary CI/CD and automation workflows in `/home/runner/work/node/node/.github/workflows/`:
- `atomic-prod.yml`
- `emoji-triggers.yml`
- `repair-any.yml`
- `universal-repair.yml`
- `elite-security-ci.yml`
- `atomic-self-healing.yml`
- `elite-ai-agent.yml`
- `swarm-dev.yml`
- `release.yml`, `elite-release.yml`, `npm-publish.yml`
- `auto-changelog.yml`, `elite-notify.yml`, `commitlint.yml`

## Freeze Policy
- V1 endpoints remain active while V2 services are introduced.
- V1 entrypoint remains `server.js` until V2 API promotion is complete.
- V1 emoji-trigger behavior is preserved by keeping `emoji-triggers.yml` unchanged.
Loading
Loading