Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
claude/adoring-hopper-5x74bqclaude/affectionate-feynman-ykrf1hclaude/architecture-audit-design-wxprenclaude/build-status-update-3MXsfclaude/charming-meitner-mllb5rclaude/compare-gate-gluecron-s4mFQclaude/confident-faraday-tikcwbclaude/continue-work-XMTlIclaude/crontech-gluecron-deploy-7MIECclaude/crontech-platform-setup-SeKfwclaude/design-2026claude/ecstatic-ptolemy-jMdigclaude/enhance-github-integration-QNHdGclaude/fix-aa-loop-issue-PonMQclaude/fix-actions-and-processclaude/fix-desktop-errors-XqoW8claude/fix-red-workflowsclaude/fix-website-access-6FKJNclaude/gatetest-integration-hardeningclaude/github-audit-improvements-bDFr9claude/gluecron-launch-status-FoMRlclaude/hopeful-lamport-olfCTclaude/issue-to-pr-and-protectionsclaude/jolly-heisenberg-2sg1Qclaude/launch-preparation-QmTb6claude/new-session-xk1l7claude/plan-platform-architecture-kkN4yclaude/platform-analysis-roadmap-1nUGLclaude/platform-launch-assessment-8dWV8claude/polish-platform-release-AeDrUclaude/resume-previous-work-KzyLwclaude/review-crontech-handoff-qYEVqclaude/review-project-completeness-lHhS2claude/review-readme-docs-ulqPKclaude/serene-edison-rj87weclaude/setup-multi-repo-dev-BCwNQclaude/ship-fixes-and-tests-Jvz1cclaude/site-audit-competitive-pctlwgclaude/site-migration-vercel-XstpKclaude/standalone-product-repos-XHFTDcopilot/feat-smart-empty-states-keyboard-first-enhancementcopilot/feat-smart-morning-digest-review-context-restorecopilot/fix-and-process-workflowscopilot/update-ai-powered-code-reviewfeat/debt-mapfeat/push-policy-codeowners-hardeningfeat/smart-digest-contextfeat/stage-impactfeat/t1-secret-migrationfeat/u-polishfeat/w-self-hostfeat/w2-claude-configfix/agent-journey-orphan-sweepgatetest/auto-fix-1776586424172gatetest/auto-fix-1776586534814gatetest/auto-fix-1776590685143gatetest/auto-fix-1776590808199mainops/redeploy-retriggerstyle/dxt-cta-themeworktree-agent-a3377aad30d55da26worktree-agent-a7ef607b7ee1d6c74
status.tsx11.5 KB · 324 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
/**
 * Public /status — human-readable platform health dashboard.
 *
 * Unlike /healthz (LB liveness JSON) and /readyz (DB readiness JSON),
 * /status renders a full HTML page anyone can load. Shows DB reachability,
 * autopilot state, totals (users/repos/gate runs), and the most recent
 * autopilot tick's task breakdown.
 *
 * Accessible without auth. Uses softAuth so the nav bar renders correctly
 * for logged-in visitors.
 */

import { Hono } from "hono";
import { sql } from "drizzle-orm";
import { db } from "../db";
import { users, repositories, gateRuns } from "../db/schema";
import { Layout } from "../views/layout";
import { softAuth } from "../middleware/auth";
import type { AuthEnv } from "../middleware/auth";
import { getLastTick, getTickCount } from "../lib/autopilot";

const status = new Hono<AuthEnv>();
status.use("*", softAuth);

const started = Date.now();

function fmtUptime(ms: number): string {
  const s = Math.floor(ms / 1000);
  const d = Math.floor(s / 86400);
  const h = Math.floor((s % 86400) / 3600);
  const m = Math.floor((s % 3600) / 60);
  if (d > 0) return `${d}d ${h}h`;
  if (h > 0) return `${h}h ${m}m`;
  return `${m}m`;
}

status.get("/status", async (c) => {
  const user = c.get("user");

  let dbOk = false;
  try {
    await db.execute(sql`SELECT 1`);
    dbOk = true;
  } catch {
    dbOk = false;
  }

  let userCount = 0;
  let repoCount = 0;
  let publicRepoCount = 0;
  let gateRunCount = 0;
  let greenRate: number | null = null;
  try {
    const [u] = await db.select({ n: sql<number>`count(*)::int` }).from(users);
    userCount = Number(u?.n ?? 0);
    const [r] = await db
      .select({ n: sql<number>`count(*)::int` })
      .from(repositories);
    repoCount = Number(r?.n ?? 0);
    const [pr] = await db
      .select({ n: sql<number>`count(*)::int` })
      .from(repositories)
      .where(sql`${repositories.isPrivate} = false`);
    publicRepoCount = Number(pr?.n ?? 0);
    const [gr] = await db
      .select({ n: sql<number>`count(*)::int` })
      .from(gateRuns);
    gateRunCount = Number(gr?.n ?? 0);
    if (gateRunCount > 0) {
      const [g] = await db
        .select({ n: sql<number>`count(*)::int` })
        .from(gateRuns)
        .where(sql`${gateRuns.status} IN ('passed','repaired')`);
      greenRate = (Number(g?.n ?? 0) / gateRunCount) * 100;
    }
  } catch {
    // counts stay 0
  }

  const tick = getLastTick();
  const ticks = getTickCount();
  const autopilotDisabled = process.env.AUTOPILOT_DISABLED === "1";
  const uptimeMs = Date.now() - started;

  const overallOk = dbOk;

  return c.html(
    <Layout title="Status — gluecron" user={user}>
      <div style="max-width: 960px; margin: 0 auto; padding: 24px 16px">
        <div style="display: flex; align-items: center; gap: 12px; margin-bottom: 8px">
          <span
            style={`display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: ${overallOk ? "var(--green, #2da44e)" : "var(--red, #cf222e)"}`}
          />
          <h1 style="margin: 0; font-size: 28px">
            {overallOk ? "All systems operational" : "Service degraded"}
          </h1>
        </div>
        <p style="color: var(--text-muted); margin-bottom: 32px">
          Live platform status. Reloads on refresh; no client-side polling.
        </p>

        <h2 style="margin-bottom: 12px; font-size: 18px">Components</h2>
        <div class="panel" style="margin-bottom: 24px">
          <div
            class="panel-item"
            style="justify-content: space-between; align-items: center"
          >
            <div>
              <strong>Database</strong>
              <div style="font-size: 12px; color: var(--text-muted)">
                Neon PostgreSQL
              </div>
            </div>
            <span
              style={`padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; background: ${dbOk ? "rgba(45, 164, 78, 0.15)" : "rgba(207, 34, 46, 0.15)"}; color: ${dbOk ? "var(--green, #2da44e)" : "var(--red, #cf222e)"}`}
            >
              {dbOk ? "operational" : "down"}
            </span>
          </div>
          <div
            class="panel-item"
            style="justify-content: space-between; align-items: center"
          >
            <div>
              <strong>Autopilot</strong>
              <div style="font-size: 12px; color: var(--text-muted)">
                Periodic platform-maintenance loop
              </div>
            </div>
            <span
              style={`padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; background: ${autopilotDisabled ? "rgba(150, 150, 150, 0.15)" : "rgba(45, 164, 78, 0.15)"}; color: ${autopilotDisabled ? "var(--text-muted)" : "var(--green, #2da44e)"}`}
            >
              {autopilotDisabled ? "disabled" : "running"}
            </span>
          </div>
          <div
            class="panel-item"
            style="justify-content: space-between; align-items: center"
          >
            <div>
              <strong>Git Smart HTTP</strong>
              <div style="font-size: 12px; color: var(--text-muted)">
                Clone, fetch, push
              </div>
            </div>
            <span style="padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; background: rgba(45, 164, 78, 0.15); color: var(--green, #2da44e)">
              operational
            </span>
          </div>
        </div>

        <h2 style="margin-bottom: 12px; font-size: 18px">Platform stats</h2>
        <div
          style="display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px"
        >
          <div class="panel" style="padding: 14px; text-align: center">
            <div style="font-size: 24px; font-weight: 700">
              {userCount.toLocaleString()}
            </div>
            <div
              style="font-size: 11px; color: var(--text-muted); text-transform: uppercase"
            >
              Developers
            </div>
          </div>
          <div class="panel" style="padding: 14px; text-align: center">
            <div style="font-size: 24px; font-weight: 700">
              {repoCount.toLocaleString()}
            </div>
            <div
              style="font-size: 11px; color: var(--text-muted); text-transform: uppercase"
            >
              Repositories
            </div>
          </div>
          <div class="panel" style="padding: 14px; text-align: center">
            <div style="font-size: 24px; font-weight: 700">
              {publicRepoCount.toLocaleString()}
            </div>
            <div
              style="font-size: 11px; color: var(--text-muted); text-transform: uppercase"
            >
              Public repos
            </div>
          </div>
          <div class="panel" style="padding: 14px; text-align: center">
            <div style="font-size: 24px; font-weight: 700">
              {gateRunCount.toLocaleString()}
            </div>
            <div
              style="font-size: 11px; color: var(--text-muted); text-transform: uppercase"
            >
              Gate runs
            </div>
          </div>
          <div class="panel" style="padding: 14px; text-align: center">
            <div style="font-size: 24px; font-weight: 700">
              {greenRate === null ? "—" : `${greenRate.toFixed(1)}%`}
            </div>
            <div
              style="font-size: 11px; color: var(--text-muted); text-transform: uppercase"
            >
              Green rate
            </div>
          </div>
          <div class="panel" style="padding: 14px; text-align: center">
            <div style="font-size: 24px; font-weight: 700">
              {fmtUptime(uptimeMs)}
            </div>
            <div
              style="font-size: 11px; color: var(--text-muted); text-transform: uppercase"
            >
              Uptime
            </div>
          </div>
        </div>

        <h2 style="margin-bottom: 12px; font-size: 18px">
          Latest autopilot tick
        </h2>
        {tick ? (
          <div class="panel" style="margin-bottom: 24px">
            <div
              class="panel-item"
              style="justify-content: space-between; font-size: 13px"
            >
              <span>Finished</span>
              <code>{tick.finishedAt}</code>
            </div>
            <div
              class="panel-item"
              style="justify-content: space-between; font-size: 13px"
            >
              <span>Total ticks this process</span>
              <code>{ticks}</code>
            </div>
            {tick.tasks.map((t) => (
              <div
                class="panel-item"
                style="justify-content: space-between; font-size: 13px"
              >
                <code>{t.name}</code>
                <span
                  style={
                    t.ok
                      ? "color: var(--green, #2da44e)"
                      : "color: var(--red, #cf222e)"
                  }
                >
                  {t.ok ? "ok" : `failed: ${t.error || "unknown"}`}
                  <span
                    style="color: var(--text-muted); margin-left: 8px"
                  >
                    {t.durationMs}ms
                  </span>
                </span>
              </div>
            ))}
          </div>
        ) : (
          <p
            style="color: var(--text-muted); margin-bottom: 24px; font-size: 14px"
          >
            {autopilotDisabled
              ? "Autopilot is disabled via AUTOPILOT_DISABLED=1."
              : "No ticks have completed yet. Check back after the first 5-minute interval elapses."}
          </p>
        )}

        <p
          style="color: var(--text-muted); font-size: 12px; margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border)"
        >
          Liveness: <a href="/healthz">/healthz</a> &middot; Readiness:{" "}
          <a href="/readyz">/readyz</a> &middot; Metrics:{" "}
          <a href="/metrics">/metrics</a> &middot; Platform JSON:{" "}
          <a href="/api/platform-status">/api/platform-status</a>
        </p>
      </div>
    </Layout>
  );
});

/**
 * Shields-style status badge. Reads the latest autopilot tick + DB
 * reachability and returns an SVG. Embed in READMEs with:
 *   ![status](https://your-host/status.svg)
 */
status.get("/status.svg", async (c) => {
  let dbOk = false;
  try {
    await db.execute(sql`SELECT 1`);
    dbOk = true;
  } catch {
    dbOk = false;
  }
  const tick = getLastTick();
  const lastOk = tick ? tick.tasks.every((t) => t.ok) : true;
  const overall = dbOk && lastOk;
  const label = "gluecron";
  const value = overall ? "operational" : "degraded";
  const fill = overall ? "#2da44e" : "#cf222e";

  const labelW = 70;
  const valueW = overall ? 78 : 68;
  const totalW = labelW + valueW;
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${totalW}" height="20" role="img" aria-label="${label}: ${value}">
  <linearGradient id="s" x2="0" y2="100%">
    <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
    <stop offset="1" stop-opacity=".1"/>
  </linearGradient>
  <rect width="${totalW}" height="20" rx="3" fill="#555"/>
  <rect x="${labelW}" width="${valueW}" height="20" rx="3" fill="${fill}"/>
  <rect width="${totalW}" height="20" rx="3" fill="url(#s)"/>
  <g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,sans-serif" font-size="11">
    <text x="${labelW / 2}" y="15">${label}</text>
    <text x="${labelW + valueW / 2}" y="15">${value}</text>
  </g>
</svg>`;
  c.header("Content-Type", "image/svg+xml; charset=utf-8");
  c.header("Cache-Control", "no-cache, max-age=0");
  return c.body(svg);
});

export default status;