Orchestrata Ultimate › Plans › plan_vizint_phase_6 › sprint-4-personal-final

Sprint 4: Personal Gadgets & Final Compliance

Source: plans/plan_vizint_phase_6/sprint-4-personal-final.md at 8a2cb42ad · last changed 2026-07-27 · first committed 2026-05-26 · 236 lines.

Prose pending.

Plan text

Sprint 4: Personal Gadgets & Final Compliance

Duration: Week 4 (32 hours)
Goal: Web Crypto, Todoist gadget, remaining constitutional items, final compliance
Target: ≥90% constitutional (128/142), 100% requirements


Day 1: Web Crypto & Plugin API (10h)

Task 1.1: Web Crypto Token Encryption (6h)

File: vizint-ui/lib/crypto.js (new)

const KEY_NAME = 'vizint-crypto-key';

export async function encryptToken(plaintext) {
  const key = await getOrCreateKey();
  const encoder = new TextEncoder();
  const iv = crypto.getRandomValues(new Uint8Array(12));
  const ciphertext = await crypto.subtle.encrypt(
    { name: 'AES-GCM', iv },
    key,
    encoder.encode(plaintext)
  );
  return { iv: arrayBufferToBase64(iv), data: arrayBufferToBase64(ciphertext) };
}

export async function decryptToken(encrypted) {
  const key = await getOrCreateKey();
  const decoder = new TextDecoder();
  const iv = base64ToArrayBuffer(encrypted.iv);
  const ciphertext = base64ToArrayBuffer(encrypted.data);
  const plaintext = await crypto.subtle.decrypt(
    { name: 'AES-GCM', iv },
    key,
    ciphertext
  );
  return decoder.decode(plaintext);
}

async function getOrCreateKey() {
  const stored = localStorage.getItem(KEY_NAME);
  if (stored) {
    return crypto.subtle.importKey('raw', base64ToArrayBuffer(stored), 'AES-GCM', false, ['encrypt', 'decrypt']);
  }
  const key = await crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, true, ['encrypt', 'decrypt']);
  const exported = await crypto.subtle.exportKey('raw', key);
  localStorage.setItem(KEY_NAME, arrayBufferToBase64(exported));
  return key;
}

Tests: tests/unit/crypto.test.js — 4 tests (encrypt, decrypt, key persistence, tamper detection)

Requirements Closed:

Task 1.2: Plugin API (4h)

File: vizint-ui/lib/registry.js

Add loadFromURL(url) method:

async loadFromURL(url) {
  const manifest = await fetch(url).then(r => r.json());
  this.register(manifest);
  return this.load(manifest.id);
}

File: vizint-ui/app.js

Add plugin loader UI (input for manifest URL + load button).

Constitutional Items Closed:


Day 2–3: Todoist Gadget (16h)

Task 2.1: TodoistGadget Implementation (12h)

File: vizint-ui/gadgets/todoist/gadget.js (new)

Features:

API Integration:

const TODOIST_API = 'https://api.todoist.com/rest/v2';

async function fetchTasks(token) {
  const res = await fetch(`${TODOIST_API}/tasks`, {
    headers: { 'Authorization': `Bearer ${token}` }
  });
  return res.json();
}

Requirements Closed:

Task 2.2: Todoist Tests (4h)

File: vizint-ui/gadgets/todoist/gadget.test.js (new)

Mock fetch API. 6 unit tests.

File: vizint-ui/tests/e2e/todoist.spec.js (new)

2 E2E tests.


Day 4: Remaining Constitutional Items (8h)

Task 4.1: Session Isolation (4h)

File: vizint-ui/bridge/state-sync.js

Add session scoping:

setSessionScope(sessionId) {
  this._sessionId = sessionId;
}

_getNamespacedKey(key) {
  const sessionPrefix = this._sessionId ? `${this._sessionId}.` : '';
  return `${NAMESPACE}${sessionPrefix}${key}`;
}

Clear session-scoped keys on session.close event.

Constitutional Items Closed:

Task 4.2: Autonomy & Governance Verification (4h)

Files: Integration tests

Add tests/integration/constitutional-autonomy.spec.js.

Constitutional Items Closed:


Day 5: Final Compliance Run (8h)

Task 5.1: Final Audit (4h)

Run all audit scripts:

cd vizint-ui
node scripts/compliance-check.js
node scripts/security-audit.js
node scripts/perf-budget.js

Update checklists with final verified items.

Task 5.2: Cleanup & Commit (4h)

Final Verification:

cd vizint-ui
npm test                              # 250+ unit tests
npx playwright test tests/e2e/        # 100+ E2E tests
npx playwright test tests/integration/# 10+ integration tests
npm run lint                          # Clean
node scripts/compliance-check.js      # 128+ items
cd /home/mohamed/workspace/orchestrata-ultimate-architecture
uv run pytest tests/gateway/ -q       # 537+ backend tests

Completed:

Results:

New Features:

Completed in This Session:

Deferred:

Exit Criteria: