# Gluecron Full-Platform Audit — 2026-06-10

**Branch:** `claude/site-audit-competitive-pctlwg` (from `main` @ `2436d1d`)
**Method:** six parallel audit agents (repair flywheel, docs freshness, wiring/mechanics, design/UX, architecture/security, live market scan) + direct verification of every load-bearing claim (test suite, typecheck, migration runner, home-route render path).
**Supersedes:** `AUDIT.md` (2026-05-16), `AUDIT-v2.md` (2026-05-16), `AUDIT_REPORT.md` (2026-05-13).

---

## 0. Executive summary

**Verdict: the platform is real, broad, and largely wired — but three things stand between today and "confidently ahead of GitHub":**

1. **The repair flywheel is built but not closed.** Every schema, tier, and helper exists; the cache lookup and the outcome-feedback loop have **zero callers**. Until those ~5 wiring points land, every repeat failure costs a 3–5 s Claude call instead of a <100 ms cache hit, and the system learns nothing from its own fixes. This is the single highest-leverage build item on the board. (§3)
2. **Quality signal was red.** The suite had 28 failing tests + 5 errors and 2 TypeScript errors — all stale assertions left behind by the Landing-2030 reboot, plus Playwright specs leaking into `bun test`. **Fixed in this session: 2767 pass / 0 fail / 122 skip, `tsc` clean.** A green suite is table stakes for due diligence. (§1)
3. **Scale posture is single-node.** Repos on local disk, in-memory rate limiting, workflow runner spawning on the web node. Fine to ~5k repos / 100 concurrent users; documented fix path below. An acquirer's tech DD will find this in week one — better that our own audit says it first, with the plan attached. (§5)

Design is genuinely on-brief (quiet, light-default, restrained violet — not cyberpunk), security fundamentals are strong (argv-array git calls, hashed tokens, AES-GCM secrets, sanitized markdown), and the June-2026 market scan says our MCP-native + self-hosted-AI-parity positioning is the most defensible wedge available. (§6, §7)

---

## 1. Verification mechanics (what was actually run)

| Check | Before this session | After this session |
|---|---|---|
| `bun test` | 2758 pass / **28 fail / 5 errors** / 122 skip | **2767 pass / 0 fail / 0 errors** / 122 skip |
| `bunx tsc --noEmit` | 2 errors (`health-score.test.ts` TS2367) | clean |
| Lockfile | `bun.lock` missing `@playwright/test` | reconciled |

**Root cause of the 28 failures — none were product breakage.** `GET /` now renders the self-contained `Landing2030Page` (`src/views/landing-2030.tsx`, wired at `src/routes/web.tsx:1865`), which does not include the master Layout CSS. Tests still asserted on the legacy `LandingPage` hero (`hero-primary-ctas`, dxt CTA, Live-now block), Layout design tokens on `/`, and the old `/status` degraded headline (`"Service degraded"` → now `"Degraded performance"` / `"Major outage"`, `src/routes/status.tsx:356`). All retargeted to the current contract (Layout assertions now hit `/help`). The 5 errors were Playwright `e2e/*.spec.ts` files crashing under Bun's runner; new `bunfig.toml` scopes `bun test` to `src/` (e2e stays on `bun run e2e`, VS Code extension suite on `bun test editor-extensions`).

**Lesson to encode:** the Landing-2030 reboot shipped without running the suite, or shipped red. Gate enforcement should apply to our own repo first — that's the product's whole pitch.

---

## 2. Wiring & mechanics audit

**Confidence: high. 188 of 190 route modules are mounted in `src/app.tsx`; all recently shipped AI features are fully wired** (ai-loop via the autopilot `ai-loop-sweep` task, AI Workspace `app.tsx:203`, cross-repo impact `app.tsx:199`, repo health `app.tsx:195`, NL search `app.tsx:167`, pair programmer `app.tsx:130` — each with its migration 0101–0104 present).

Verified end-to-end: the 14-step `src/hooks/post-receive.ts` chain (auto-repair → intelligence → gates → semantic index → AI auto-issues → preview builds → dep scan → doc-drift → onboarding → cloud deploys → Crontech webhook (HMAC, 6-attempt backoff) → server targets → **self-deploy**). `scripts/self-deploy.sh` exists (15.5 KB, executable) and is invoked via `Bun.spawn` at `post-receive.ts:241-267`, gated on `SELF_HOST_REPO` + push to `refs/heads/main` — the CLAUDE.md "self-driven deploys" claim is true.

Issues found:

| # | Finding | Action |
|---|---|---|
| W1 | `src/routes/migration-assistant.tsx` exists but is never imported/mounted (superseded by `migrate.tsx`) | Delete in a cleanup block |
| W2 | `src/lib/changelog-generator.ts` has zero importers (`ai-generators.ts generateChangelog` is the live path) | Delete in a cleanup block |
| W3 | Migration prefixes duplicated (0077×3, 0078×2) and 0085 missing | **Safe — verified directly:** `src/db/migrate.ts:137` tracks applied migrations by full filename, so each file applies exactly once. **Do NOT renumber** — renaming an applied file would re-run it. Convention only: next migrations continue from 0105. |
| W4 | 6 env vars used in `src/lib/config.ts` were undocumented | `.env.example` updated this session |
| W5 | ~20 TODO markers in src/, none blocking | No action |

---

## 3. The repair flywheel (owner priority) — built, not closed

Owner vision: record everything; at 10k–20k repos, recognize recurring breakages and fix them deterministically **in seconds, without an AI call**, reserving AI for novel failures.

**Status: the architecture is ~80 % present and ~0 % operational as a learning loop.**

What exists and works:
- `repair_flywheel` table (`drizzle/0039_repair_flywheel.sql`) — failure SHA-256 fingerprint, `repair_tier` (cached/mechanical/ai-sonnet/human), outcome, `cache_hit_count`, cross-repo `is_public_pattern`, and the hot-path composite index `(repo_id, failure_signature, outcome)`. The data model is exactly right for the vision.
- Tier 1 mechanical repairs (`src/lib/auto-repair-mechanical.ts`) — lockfile drift, formatting, import-order classification + worktree-safe fixes.
- Tier 2 AI repair (`src/lib/auto-repair.ts`) and CI autofix (`src/lib/ci-autofix.ts`) — real Sonnet calls, patch-as-comment.
- Recording: `recordRepair()` writes attempts with fingerprints.
- `recurring_patterns` (0096) — Claude-detected recurring issues, used for PR warnings.

What is broken (the gaps, with file:line):

| Gap | Evidence |
|---|---|
| **Tier-0 cache is never consulted** | `findCachedRepair()` `src/lib/repair-flywheel.ts:112` — zero callers anywhere. Every failure goes straight to mechanical/AI. |
| **Outcomes are never recorded** | `updateOutcome()` `repair-flywheel.ts:252` — zero callers. Every row stays `outcome='pending'` forever; success-rate stats are blind; the cache can never be trusted. |
| **The tier orchestrator is dead code** | `repairGateFailure()` `src/lib/auto-repair.ts:412-587` (the Tier-1→2 fallthrough) is defined and never called. Live call sites only repair secrets/security (`src/lib/gate.ts:424-450`); ordinary CI test failures bypass tiers and go straight to Sonnet via `triggerCiAutofix` (`src/lib/ci-autofix.ts:155`). |
| **No AI→deterministic promotion** | Nothing moves a repeatedly successful AI fix into the Tier-0 cache or flips `is_public_pattern`. |
| **No operator surface** | `getFlywheelStats()` (`repair-flywheel.ts:286-380`) has no route — no `/admin/repair-flywheel`. |
| **ai-loop skips the cache too** | `src/lib/ai-loop.ts:441` calls `triggerCiAutofix` without a cache lookup. |

**Closing plan (proposed BLOCK N1 — small, surgical, ~5 wiring points):**
1. `ci-autofix.ts` (~line 156): fingerprint the parsed error; `findCachedRepair()` first; on a high-success-rate hit, apply the cached patch and record a `cached`-tier row — no AI call.
2. `ai-loop.ts:441`: same cache-first check before dispatching autofix.
3. Post-gate-rerun correlation: when a gate re-runs after a repair, match the new `gate_runs` row back to the open `repair_flywheel` row and call `updateOutcome('success'|'failed')`. This is the linchpin.
4. Promotion: on N successes for a signature, mark the pattern public (cross-repo) and increment `cache_hit_count` on every hit.
5. `/admin/repair-flywheel` route exposing `getFlywheelStats()` — hit rate, AI-vs-cache ratio, $-saved. (Also a powerful acquisition metric: "x % of failures fixed without a model call.")

Also: repairs should write `audit_log` rows (no `repair_*` actions exist today), so the "record everything" half of the vision holds.

---

## 4. Architecture & security

**Strong fundamentals (verified):**
- No command injection: all git subprocess calls use argv arrays (`src/git/repository.ts:42-58`); no `bash -c` interpolation of user input.
- Auth: all 10 sampled mutating routes gated (`requireAuth` / `repo-access` 5-tier hierarchy / API scopes); session cookies `httpOnly` + `secure` (prod) + `sameSite=Lax`.
- Secrets: workflow secrets AES-256-GCM with per-encryption IVs (`src/lib/workflow-secrets-crypto.ts`); PATs and OAuth tokens stored SHA-256-hashed.
- XSS: markdown pipeline escapes HTML/attrs and rejects `javascript:`/`data:` hrefs (`src/lib/markdown.ts`); no user-data `dangerouslySetInnerHTML`.
- Global error handler upholds the "no 500 reaches the UI" invariant (`src/app.tsx:886-906`).

**Findings to fix:**

| Sev | Finding | Fix |
|---|---|---|
| HIGH | **SSRF**: webhook delivery (`src/lib/webhook-delivery.ts:201`) and mirror fetch (`src/lib/mirrors.ts`) fetch user-supplied URLs with no private-range block (127.0.0.1, 10/8, 172.16/12, 192.168/16, 169.254/16, ::1) | ~2 days: shared `assertPublicUrl()` helper + DNS-resolution check, applied to webhooks, mirrors, imports |
| HIGH | Single-node coupling: bare repos on local disk (`repository.ts:38`), in-memory rate limiter (`rate-limit.ts:15`), workflow runner in-process on the web node, 500-entry session cache. SSE already has a Redis fallback (`sse.ts:76-150`) — the others don't | Document the supported topology now (done here); BLOCK N3: Redis-backed rate-limit + sessions, extract workflow runner to a worker process, repo-storage strategy (shared volume now, object-store later) |
| MED | Silent async failures: post-receive side-effects swallow errors with bare `.catch(() => {})` — operators can't see when AI analysis/indexing silently dies | Route through `reportError` + a failures counter on `/metrics` |
| MED | N+1 queries on PR/issue list pages (per-row risk-score + comment-count queries) | Batch with joins; add a slow-query log |
| MED | Test gaps: no Smart-HTTP protocol tests; `mcp-tools-expanded.ts` (2,470 lines of write tools) has no test file | BLOCK N4: MCP write-tool suite + git-protocol smoke tests |
| LOW | `src/routes/pulls.tsx` is 6,654 lines (merge logic also duplicated in `pr-merge.ts` + MCP merge tool — known §7 Bible follow-up) | Consolidate on `performMerge()` |

Dependency hygiene is good: 8 runtime deps, all mainstream, no abandonware.

---

## 5. Design & UX (brief: quiet confidence, believable, not cyberpunk)

Two design systems are live:
- **App + legacy marketing surfaces** — `src/views/layout.tsx` "Editorial-Technical" system: 60+ CSS custom properties, slate-noir `#08090f` / violet `#8c6dff` / hairline borders, Inter + Inter Tight + JetBrains Mono, light/dark with pre-paint script, 52 ARIA attributes, `prefers-reduced-motion` respected, 12:1–15:1 text contrast. Scored **8.2/10 against the brief** — restraint comparable to Linear/Vercel-tier marketing; no neon, no glow-noise.
- **The actual home page** — `Landing2030Page` (`src/views/landing-2030.tsx`): white-background, ink-on-paper, light-only, headline "The git host built for 2030," fact-led copy ("Spec to PR in 90 seconds"), one product-card mock, two CTAs. This is precisely the "believable, it-just-works" register the owner asked for (closest public analog: vapi.ai's developer-infra restraint — note: **vapron.ai does not exist**; vapi.ai is the real benchmark).

Highest-impact polish items (ordered):
1. Social proof strip on the landing (grayscale logos / "powering N repos" with real counters) — the one missing trust signal for acquirers.
2. Consolidate scattered "vs GitHub" copy into the existing `/vs-github` page; keep the landing comparison to one pull-quote.
3. Unify modal/dropdown shadow recipes to one `--modal-shadow` token.
4. CTA label case consistency ("Start building" / "Sign in" — title-vs-sentence drift).
5. Disable decorative animations on mobile/slow networks (`prefers-reduced-motion` + width guard).
6. Empty-state noise reduction (dashed borders + dot grids accumulate on data-less dashboards).
7. Status dot in the footer linking `/status` (operational-health-as-brand).
8. `:focus-visible` outlines on landing CTAs (currently box-shadow only).
9. Brand naming is already consistent (lowercase `gluecron`) — keep it that way in new copy.
10. Decide the long-term fate of the legacy `LandingPage`/marketing routes — two design systems is one too many for an acquirer walkthrough.

---

## 6. Documentation freshness (fixed this session)

| Doc | Was | Now |
|---|---|---|
| `BUILD_BIBLE.md:3` | "Last updated 2026-05-29" | 2026-06-10 + living-document rule |
| `BUILD_BIBLE.md` §4.1 | "95 tables" | 161 tables (verified by count) |
| `BUILD_BIBLE.md` §5.1 | "1491 tests pass as of 2026-05-13" | 2767/0/122 as of 2026-06-10 + runner scoping note |
| `CLAUDE.md` architecture tree | implied ~20 route files | annotated: illustrative; ~190 route files, 161 tables |
| `AUDIT.md`, `AUDIT-v2.md`, `AUDIT_REPORT.md` | presented as current | stamped SUPERSEDED → this file |
| `.env.example` | 6 config vars undocumented | documented |

Verified accurate, no change needed: `README.md` (15 MCP read-tools claim matches `defaultTools()`), `ROADMAP.md`, `docs/STRATEGY.md`, `DEPLOY.md`.

**Standing rule going forward:** every audit/spec doc carries a date in its filename or header, and the Bible's header timestamp moves in the same commit that changes reality.

---

## 7. Market scan (June 2026) and the capability gap list

Full sourced report retained from the research agent; condensed here.

**Where the market is:** GitHub absorbed Copilot Workspace into the GA coding agent + Agent HQ (multi-vendor agents — Anthropic/OpenAI/Google/Cognition/xAI — under one mission-control panel; agentic code review on all PRs since March 2026, review→agent autofix handoff). GitLab Duo Agent Platform GA'd Jan 2026 with credits-based pricing and agentic SAST fix PRs. Cursor (~$29B, >$2B ARR) runs Bugbot on ~2M PRs/month with >35 % of its autofix PRs merging. OpenAI Codex reviews GitHub PRs natively with `AGENTS.md` steering. Claude Code passed ~$2.5B annualized with MCP as the de-facto agent-integration standard (~9,400 public servers). **Closed-loop autonomy (review → fix → CI → self-heal) is the 2026 frontier — which is exactly the flywheel §3 closes.**

**Gluecron's defensible wedges (per the scan):**
1. **MCP-native git host with a deep write surface + governance** — per-token scopes, full agent audit trail, org policy on tool access. The "MCP governance gap" is documented and unowned by any incumbent.
2. **Self-hosted with day-one AI parity** (GHES lags github.com on AI; we don't).
3. **Agent identity & provenance** — agents as first-class actors with attribution ("agent X under human Y"), signed agent commits, agent activity feed.

**Capability checklist for market leadership (T = table stakes, D = differentiator; ✅ = shipped, 🟡 = partial):**

| # | Capability | T/D | Status |
|---|---|---|---|
| 1 | Issue→PR coding agent (sandboxed, tests run) | T | ✅ spec-to-PR + ai:build label |
| 2 | Auto AI review on every PR, inline comments | T | ✅ |
| 3 | **Review→fix closed loop on same PR** | T | 🟡 ci-autofix posts patches; flywheel not closed (§3) |
| 4 | Severity-filtered review (P0/P1-only mode, effort levels) | T | ❌ |
| 5 | Honor `AGENTS.md`/`CLAUDE.md` steering files in all AI flows | T | 🟡 partial |
| 6 | **Multi-vendor agent panel** (Claude + Codex + Gemini + Devin side-by-side, compare PRs) | D | ❌ — GitHub Agent HQ is the template; no self-hosted product has it |
| 7 | Parallel agent sessions in isolated worktrees + diff-compare view | D | 🟡 PR sandboxes exist; no compare UI |
| 8 | **Self-healing CI** (red pipeline → agent reads logs → fix → re-run) | T | 🟡 = §3 flywheel close |
| 9 | Natural-language CI authoring | D | ❌ — pre-GA everywhere; leadership claimable |
| 10 | Security scan + AI autofix default-on | T | ✅ gates + repair |
| 11 | Autonomous maintenance agents (dep bumps ✅, dead-code, flaky-test quarantine, coverage PRs) | D | 🟡 |
| 12 | First-class MCP server over the whole host surface | T | ✅ 15 + 10 write tools |
| 13 | **MCP governance**: OAuth remote MCP, per-token tool scopes, agent-action audit log, org tool policy | D | 🟡 auth exists; scoping/policy/audit-views don't |
| 14 | Agent identity & provenance (first-class agent actors, attribution) | D | 🟡 app-bots exist; §7 Bible notes marker comments still credit humans |
| 15 | Persistent context spaces (pin docs/issues/files as reusable agent grounding) | D | ❌ |
| 16 | Headless API/SDK so any agent CLI treats Gluecron as a first-class remote | D | ✅ REST v2 + GraphQL + CLI |
| 17 | Consumption/credit billing rail for agent work | T | 🟡 plans/quotas exist; no metering |
| 18 | Agent analytics: % agent-authored merged code, fix-acceptance rate, cycle-time delta | T | 🟡 DORA + hours-saved exist; not agent-cut |
| 19 | Per-repo review memory ("never flag this again") | D | ❌ |
| 20 | AI issue triage (label/dedupe/severity/route-to-agent) | D | ✅ |
| 21 | Auto-merge policy gated on AI review + CI green | T | ✅ K2/K3 |
| 22 | Self-hosted full AI parity | D | ✅ — say it louder in marketing |
| 23 | Browser/runtime verification subagent (screenshot evidence on PRs) | D | ❌ — nobody attaches this to hosting review yet |
| 24 | Daily automated market/competitor scan feeding the roadmap | D | 🟡 `advancement-scanner` lib exists and is tested — point it at competitor changelogs + RSS and open `ai:build` issues automatically |
| 25 | Repair-flywheel economics on the admin dashboard (% fixed without AI, seconds-to-fix) | D | ❌ until §3 closes |

**Recommended build order (next blocks):**
- **N1 — Close the repair flywheel** (§3, ~1 week). Unlocks #3, #8, #25 and the headline acquisition metric.
- **N2 — SSRF guard + MCP write-tool test suite** (~1 week). Closes both HIGH security/test findings.
- **N3 — Multi-node readiness** (Redis rate-limit/sessions, worker-process workflow runner, storage doc) (~3 weeks).
- **N4 — MCP governance + agent provenance** (#13, #14) (~2–3 weeks). The differentiator no incumbent owns.
- **N5 — Multi-vendor agent panel** (#6, #7) (~3–4 weeks). The "Agent HQ for the self-hosted world" story.
- **N6 — Review noise controls + per-repo review memory** (#4, #19) (~2 weeks). The #1 buyer complaint in the AI-review market.
- **N7 — Daily market scanner** (#24): schedule `advancement-scanner` in autopilot against competitor feeds; weekly digest to the owner.

---

## 8. Acquisition-readiness checklist

Signals the 2025–26 M&A record says to manufacture (Cursor/Cognition/Graphite precedents):

| Signal | Status |
|---|---|
| Green test suite + clean typecheck on `main` | ✅ as of this session — keep it gated |
| % of merged code that is agent-authored (platform metric) | ❌ build with N1/#18 |
| AI-review fix-acceptance / auto-merge rate (Cursor publicizes 80 % / 35 %) | ❌ data exists in tables; needs the analytics cut |
| MCP tool-call volume from third-party agents (proves *platform*, not feature) | 🟡 log exists; no dashboard |
| 2–3 enterprise logos on self-hosted | ❌ go-to-market |
| Consumption billing live | 🟡 plans exist, metering doesn't |
| Clean IP / no exclusive model-vendor dependency | 🟡 Anthropic-first; Voyage optional; keep model layer swappable (`MODEL_*` constants already centralize this) |
| Single current audit doc + reconciled Bible | ✅ this file |

---

*Next scheduled audit: 2026-07-10 or after BLOCK N3, whichever comes first. Keep this file's date in the filename; supersede, don't edit history.*
