Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesPull RequestsActionsSecurityInsightsSettings
✨ AI
More
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-sweepfix/audit-sweep-2026-07-26gatetest/auto-fix-1776586424172gatetest/auto-fix-1776586534814gatetest/auto-fix-1776590685143gatetest/auto-fix-1776590808199mainops/redeploy-retriggerstyle/dxt-cta-themeworktree-agent-a3377aad30d55da26worktree-agent-a7ef607b7ee1d6c74
nav-audit.ts11.7 KB · 317 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
// nav-audit — press every tab, on every page, and confirm it actually renders.
//
// The gap this closes: prior "audits" checked API endpoints (doctor.ts),
// the git/PR write flow (agent-journey.ts), or curl'd a few status codes and
// mis-triaged 404s as "expected". None of them pressed every navigation
// destination and confirmed the page renders. This does — and it's meant to
// run before ANY "production ready" claim, and against every repo you import.
//
// Two modes:
//   (default)            audit the Gluecron self-host repo's every tab
//   --repo owner/name    audit one specific repo's tabs
//   --all-repos          audit EVERY repo on the instance
//   --crawl <baseUrl>    generic same-origin link crawl of ANY site
//                        (works on vapron.ai, gluecron.com, any platform)
//
// Env:
//   GLUECRON_HOST   target instance (default https://gluecron.com)
//   GLUECRON_PAT    bearer token — needed to reach private repos / admin
//   NAV_SLOW_MS     "slow render" threshold (default 8000)
//
// Exit: 0 iff every checked page returns 2xx/3xx and renders without an
// error body. Non-zero (and a FAIL table) otherwise.

const HOST = (process.env.GLUECRON_HOST || "https://gluecron.com").replace(/\/+$/, "");
const PAT = process.env.GLUECRON_PAT?.trim() || "";
const SLOW_MS = Number(process.env.NAV_SLOW_MS || 8000);

const argv = process.argv.slice(2);
const flag = (name: string): string | undefined => {
  const i = argv.indexOf(name);
  return i >= 0 ? argv[i + 1] : undefined;
};

type Row = {
  group: string;
  label: string;
  url: string;
  status: number;
  ms: number;
  ok: boolean;
  note: string;
  body?: string; // captured for 2xx so --crawl can extract links without re-fetching
};

// SECURITY: only ever send the Gluecron PAT to the Gluecron origin. In
// --crawl mode against another platform (vapron.ai, etc.) we must NOT leak
// the token to a different host.
let HOST_ORIGIN = "";
try {
  HOST_ORIGIN = new URL(HOST).origin;
} catch {
  /* HOST malformed — no auth will be attached */
}
function authHeaders(url: string): Record<string, string> {
  if (!PAT) return {};
  try {
    if (new URL(url).origin === HOST_ORIGIN) return { authorization: `Bearer ${PAT}` };
  } catch {
    /* unparseable URL — send nothing */
  }
  return {};
}

// A 200 that renders an error page still counts as broken. Sniff the title +
// obvious error markers.
function errorBody(html: string): string {
  const title = (html.match(/<title>([^<]*)<\/title>/i)?.[1] || "").trim();
  if (/(^|\s)(not found|error|forbidden|something went wrong)(\s|$)/i.test(title)) {
    return `error title: "${title}"`;
  }
  if (/>\s*4\d\d\s*<|Page not found|Internal Server Error|Application error/i.test(html)) {
    return "error content in body";
  }
  return "";
}

async function hit(group: string, label: string, path: string): Promise<Row> {
  const url = path.startsWith("http") ? path : HOST + path;
  const t0 = Date.now();
  try {
    const res = await fetch(url, { headers: authHeaders(url), redirect: "manual" });
    const ms = Date.now() - t0;
    let note = "";
    let ok = res.status >= 200 && res.status < 400;
    let body: string | undefined;
    if (res.status >= 200 && res.status < 300) {
      body = await res.text();
      const eb = errorBody(body);
      if (eb) {
        ok = false;
        note = eb;
      }
    } else if (res.status >= 400) {
      ok = false;
      note = `HTTP ${res.status}`;
    }
    if (ok && ms > SLOW_MS) {
      ok = false;
      note = `slow render ${ms}ms (> ${SLOW_MS}ms)`;
    }
    return { group, label, url, status: res.status, ms, ok, note, body };
  } catch (err) {
    return {
      group,
      label,
      url,
      status: 0,
      ms: Date.now() - t0,
      ok: false,
      note: `fetch failed: ${(err as Error).message}`,
    };
  }
}

// ── Known Gluecron destinations (repo-scoped templates + global) ─────────────

const REPO_TABS: Array<[string, string]> = [
  ["Code", ""],
  ["Issues", "/issues"],
  ["Pull Requests", "/pulls"],
  ["Actions", "/actions"],
  ["Security", "/security/vulnerabilities"],
  ["Insights", "/insights"],
  ["Settings", "/settings"],
  ["AI:Explain", "/explain"],
  ["AI:Ask", "/ask"],
  ["AI:Workspace", "/workspace"],
  ["AI:Spec", "/spec"],
  ["AI:Tests", "/ai/tests"],
  ["AI:NL Search", "/search/nl"],
  ["AI:Debt Map", "/debt-map"],
  ["AI:Archaeology", "/archaeology"],
  ["More:Commits", "/commits"],
  ["More:Discussions", "/discussions"],
  ["More:Wiki", "/wiki"],
  ["More:Projects", "/projects"],
  ["More:Releases", "/releases"],
  ["More:Contributors", "/contributors"],
  ["More:Pulse", "/pulse"],
  ["More:Gates", "/gates"],
  ["More:Deployments", "/cloud-deployments"],
  ["More:Pipeline", "/pipeline"],
  ["More:Agents", "/agents"],
  ["More:Traffic", "/traffic"],
];

const INSIGHT_REPORTS: Array<[string, string]> = [
  ["Insights hub", "/insights"],
  ["DORA", "/insights/dora"],
  ["Velocity", "/insights/velocity"],
  ["Health", "/insights/health"],
  ["Hot files", "/insights/hotfiles"],
  ["Bus factor", "/insights/bus-factor"],
  ["Test gaps", "/insights/test-gaps"],
  ["Engineering", "/insights/engineering"],
  ["Coupling", "/coupling"],
  ["Dependencies", "/dependencies"],
  ["Repo health", "/health"],
];

const SETTINGS_PAGES = [
  "/settings", "/settings/keys", "/settings/signing-keys", "/settings/2fa",
  "/settings/passkeys", "/settings/sessions", "/settings/tokens",
  "/settings/notifications", "/settings/replies", "/settings/billing",
  "/settings/sponsors", "/settings/applications", "/settings/apps",
  "/settings/authorizations", "/settings/agents", "/settings/deploy-targets",
  "/settings/integrations", "/settings/incident-hooks", "/settings/audit",
];

const ADMIN_PAGES = [
  "/admin", "/admin/command", "/admin/ops", "/admin/health", "/admin/env-health",
  "/admin/status", "/admin/self-host", "/admin/diagnose", "/admin/users",
  "/admin/repos", "/admin/flags", "/admin/security", "/admin/soc2",
  "/admin/deletions", "/admin/stripe", "/admin/google-oauth", "/admin/github-oauth",
  "/admin/sso", "/admin/ai-costs", "/admin/growth", "/admin/autopilot",
  "/admin/digests", "/admin/integrations", "/admin/advancement", "/admin/deploys",
  "/admin/autopilot/health",
];

const GLOBAL_PAGES = [
  "/", "/explore", "/dashboard", "/notifications", "/activity", "/pricing",
  "/status", "/help", "/docs", "/changelog",
];

type Spec = { group: string; label: string; path: string };

function repoSpecs(ownerRepo: string): Spec[] {
  const base = `/${ownerRepo}`;
  return [
    ...REPO_TABS.map(([label, sub]) => ({ group: `repo:${ownerRepo}`, label, path: base + sub })),
    ...INSIGHT_REPORTS.map(([label, sub]) => ({ group: `insights:${ownerRepo}`, label, path: base + sub })),
  ];
}

function globalSpecs(): Spec[] {
  return [
    ...GLOBAL_PAGES.map((p) => ({ group: "global", label: p, path: p })),
    ...SETTINGS_PAGES.map((p) => ({ group: "settings", label: p, path: p })),
    ...ADMIN_PAGES.map((p) => ({ group: "admin", label: p, path: p })),
  ];
}

// Bounded-concurrency runner so ~90+ pages finish in seconds, not minutes.
async function runConcurrent(specs: Spec[], concurrency = 10): Promise<Row[]> {
  const rows: Row[] = new Array(specs.length);
  let next = 0;
  async function worker() {
    while (true) {
      const i = next++;
      if (i >= specs.length) return;
      const s = specs[i];
      rows[i] = await hit(s.group, s.label, s.path);
    }
  }
  await Promise.all(Array.from({ length: Math.min(concurrency, specs.length) }, worker));
  return rows;
}

async function listAllRepos(): Promise<string[]> {
  // Best-effort: enumerate the authed user's repos, then their org repos.
  const out = new Set<string>();
  try {
    const me = await fetch(HOST + "/api/v2/user", { headers: authHeaders(HOST + "/api/v2/user") }).then((r) => r.json());
    if (me?.username) {
      const reposUrl = HOST + `/api/v2/users/${encodeURIComponent(me.username)}/repos`;
      const repos = await fetch(reposUrl, { headers: authHeaders(reposUrl) }).then((r) => r.json());
      if (Array.isArray(repos)) for (const r of repos) if (r?.name) out.add(`${me.username}/${r.name}`);
    }
  } catch { /* fall through */ }
  return [...out];
}

// ── Generic same-origin crawler (works on ANY site) ──────────────────────────

const DANGER = /(logout|sign-?out|delete|destroy|revoke|remove|\/raw\/|\/git-|uninstall|disable|reset|purge|cancel|deactivate)/i;

async function crawlSite(startUrl: string, maxPages = 150): Promise<Row[]> {
  const origin = new URL(startUrl).origin;
  const seen = new Set<string>();
  const queue: string[] = [startUrl];
  const rows: Row[] = [];
  while (queue.length && seen.size < maxPages) {
    const url = queue.shift()!;
    if (seen.has(url)) continue;
    seen.add(url);
    const row = await hit("crawl", new URL(url).pathname || "/", url);
    rows.push(row);
    // Only expand links from pages that rendered. Reuse the body hit()
    // already captured — no second fetch of a (possibly slow) page.
    if (row.status >= 200 && row.status < 300 && !row.note && row.body) {
      try {
        const html = row.body;
        const hrefs = [...html.matchAll(/href="([^"#?]+)"/gi)].map((m) => m[1]);
        for (const href of hrefs) {
          if (DANGER.test(href)) continue;
          let abs: string;
          try {
            abs = new URL(href, url).toString();
          } catch {
            continue;
          }
          if (!abs.startsWith(origin)) continue;
          if (DANGER.test(abs)) continue;
          if (!seen.has(abs) && !queue.includes(abs)) queue.push(abs);
        }
      } catch { /* ignore link-extract errors */ }
    }
  }
  return rows;
}

// ── Report ───────────────────────────────────────────────────────────────────

function report(rows: Row[]): number {
  const fails = rows.filter((r) => !r.ok);
  const slow = rows.filter((r) => r.ok && r.ms > SLOW_MS / 2);
  console.log(`\n# nav-audit — ${HOST}${new Date().toISOString()}`);
  console.log(`# ${rows.length} pages checked · PAT ${PAT ? "present" : "absent"}\n`);
  if (fails.length) {
    console.log(`## FAILURES (${fails.length})\n`);
    console.log("status | ms    | group / label → url | note");
    console.log("-------+-------+---------------------+-----");
    for (const r of fails) {
      console.log(`${String(r.status).padStart(6)} | ${String(r.ms).padStart(5)} | ${r.group} / ${r.label}${r.url} | ${r.note}`);
    }
    console.log("");
  }
  if (slow.length) {
    console.log(`## SLOW (ok but > ${Math.round(SLOW_MS / 2)}ms) — worth a look\n`);
    for (const r of slow) console.log(`  ${String(r.ms).padStart(6)}ms  ${r.group} / ${r.label}`);
    console.log("");
  }
  const passed = rows.length - fails.length;
  console.log(fails.length === 0 ? `nav-audit: ALL GREEN — ${passed}/${rows.length} pages render` : `nav-audit: ${fails.length} FAILURE(S) — ${passed}/${rows.length} render`);
  return fails.length === 0 ? 0 : 1;
}

async function main() {
  let rows: Row[] = [];
  const crawlUrl = flag("--crawl");
  if (crawlUrl) {
    console.log(`crawling ${crawlUrl} (same-origin, GET-only, safe)…`);
    rows = await crawlSite(crawlUrl);
  } else if (argv.includes("--all-repos")) {
    const repos = await listAllRepos();
    console.log(`auditing ${repos.length} repos + global/settings/admin…`);
    const specs = [...globalSpecs(), ...repos.flatMap(repoSpecs)];
    rows = await runConcurrent(specs);
  } else {
    const repo = flag("--repo") || "ccantynz/Gluecron.com";
    console.log(`auditing repo ${repo} + global/settings/admin…`);
    rows = await runConcurrent([...globalSpecs(), ...repoSpecs(repo)]);
  }
  process.exit(report(rows));
}

main();