Files
insights/frontend/bin/post-eager-graph-comment.mjs
zeekay 1b367e2b62 chore: rebase the tree onto upstream master
The tree was a debranded snapshot of upstream taken around 2026-02-20, and
upstream has moved about five months since. This replaces it with upstream
master, mechanically re-derived: bin/debrand does the rename, and the
pipeline and squashed migrations are restored from the shipped tree.

Not a merge. The previous import replaced the tree wholesale in a single
commit, so there is no shared content history to merge against. Reproducing
the rename on the new tree is what actually converges.

What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints,
compose files, LLM.md, and insights/migrations. The squashed initial
migration is load-bearing — the live database records it by name, so
upstream's ~918 individual migrations cannot come back.

Nine products are dropped as unreferenced. Twenty-one more that we do not run
are kept anyway because the core app still imports them; unpicking those is a
refactor and does not belong in a rebase.

This base does not build yet, and the reasons are not in the rename:
upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against
our 4.2, and the dependency manifests still name upstream packages that we
republish under our own names. Those are decisions, not renames.
2026-08-01 15:44:40 -07:00

78 lines
3.3 KiB
JavaScript

#!/usr/bin/env node
import { formatBytes, formatDelta } from './ci-report/format.mjs'
import { resolvePrAndBaseReport } from './ci-report/report-files.mjs'
import { postSection } from './ci-report/update-ci-report.mjs'
const resolved = resolvePrAndBaseReport('eager-graph-report', 'eager graph')
if (!resolved) {
process.exit(0)
}
const { report, baseReport } = resolved
const baseBytes = Object.fromEntries((baseReport?.roots ?? []).map((r) => [r.root, r.bytes]))
function budgetBar(bytes, budgetBytes) {
const ratio = Math.min(bytes / budgetBytes, 1)
const filled = Math.round(ratio * 10)
const bar = '█'.repeat(filled) + '░'.repeat(10 - filled)
return `\`${bar}\` ${((bytes / budgetBytes) * 100).toFixed(1)}% of ${formatBytes(budgetBytes)}`
}
const errorCount = report.errors?.length ?? 0
const overBudgetRoots = report.roots.filter((r) => r.overBudget).length
const forbiddenCount = report.roots.reduce((n, r) => n + r.forbiddenHits.length, 0)
const anyFailure = Boolean(errorCount || overBudgetRoots || forbiddenCount)
const problems = [
overBudgetRoots && `${overBudgetRoots} over budget`,
forbiddenCount && `${forbiddenCount} forbidden import(s)`,
].filter(Boolean)
const summary = errorCount ? `${errorCount} error(s)` : problems.join(', ') || 'within budget'
const lines = [
'How much code each root ships on the *eager* path — downloaded and parsed before the surface is interactive. Measured from the esbuild output chunks (post-tree-shake, static imports only); lazy `import()` / `React.lazy` chunks are not counted.',
'',
'| Root | Eager (shipped) | Δ vs base | Budget |',
'| --- | --- | --- | --- |',
]
for (const r of report.roots) {
const status = r.overBudget ? '🟡 ' : ''
lines.push(
`| ${status}**${r.label}**<br/>\`${r.root}\` | ${formatBytes(r.bytes)} · ${r.files.toLocaleString()} files | ${formatDelta(r.bytes, baseBytes[r.root], { noBaseline: '_(no base measurement)_' })} | ${budgetBar(r.bytes, r.budgetBytes)} |`
)
}
lines.push('')
for (const message of report.errors ?? []) {
lines.push(`🟡 ${message}`, '')
}
for (const r of report.roots) {
for (const forbiddenModule of r.forbidden) {
const hit = r.forbiddenHits.find((h) => h.module === forbiddenModule)
if (hit) {
lines.push(`🟡 \`${forbiddenModule}\` ships eagerly from \`${r.root}\`:`)
lines.push('', '```', hit.chain.join('\n -> '), '```')
} else {
lines.push(`🟢 \`${forbiddenModule}\` stays out of \`${r.root}\``)
}
}
}
lines.push('')
for (const r of report.roots) {
lines.push(`<details><summary>Largest files eagerly shipped from <code>${r.root}</code></summary>`, '')
lines.push('| Size | File |', '| --- | --- |')
for (const { file, bytes } of r.largest.slice(0, 10)) {
lines.push(`| ${formatBytes(bytes)} | \`${file}\` |`)
}
lines.push('', '</details>')
}
lines.push('')
lines.push(
'<sub>Posted automatically by [check-eager-graph](https://github.com/Insights/insights/blob/master/frontend/bin/check-eager-graph.mjs) · sizes are eager output bytes (shipped, post-tree-shake) from the esbuild metafile · part of #32479</sub>'
)
await postSection({
id: 'eager-graph',
status: anyFailure ? 'warn' : 'ok',
summary,
body: lines.join('\n'),
})