mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-20 05:42:19 +03:00
Owner decision (2026-08-30): shipping speed matters more than holding the debt line
until the v4.0 LTS modularization; the base was going red on every merge batch and
each red baseline cost a sweep.
Relaxation (one auditable pass, scripts/quality/relax-baselines.mjs):
- quality-baseline.json metrics: lower-is-better ×1.2, higher-is-better ÷1.2
(coverage floor 60 kept; eslintErrors stays 0; eslintWarnings 0 → 1050 = 20% of
the 5,247 frozen suppressions). Adds `_policy {phase: velocity, until: 4.0.0,
relaxPct: 20, requireTighten: false}` + a `_relax_velocity_2026_08_30` note
listing every before → after.
- complexity count 2681 → 3218; duplication 5.72 → 6.86; file-size cap/testCap
1000 → 1200 and all 127 frozen caps ×1.2; api/dashboard/open-sse typecheck
per-file counts ×1.2; openapi-coverage THRESHOLD 36 → 30.
- check-quality-ratchet: --require-tighten is advisory while _policy.requireTighten
is false (2 new tests); nightly bank-ratchet-shrinks pauses during the phase (it
would bank the measured shrink and undo the headroom every night).
Monitoring (scripts/quality/baseline-headroom.mjs, npm run quality:headroom):
measures each numeric gate the way CI does, prints live / baseline / headroom per
gate (ok ≥10%, warn <10%, critical <0); the new nightly `baseline-headroom` job
posts the table to the living issue "📈 Baseline headroom (velocity phase)" and
toggles the `headroom-alert` label. 6 unit tests on the pure helpers.
Also aligns the remaining red tests on the tip to contracts already merged:
#11775 (FREE lease-capable connections are ordinary capacity: gate inventory 48/97/99,
sse-auth selection, warmup scheduler), #11794 (dual-loopback readiness probe), and the
8 vi strings #11775 left as __MISSING__.
Docs: QUALITY_GATES.md → "Velocity phase" (what changed, tooling, how to close the
phase at 4.0), AGENTS.md quick reference.
99 lines
3.2 KiB
TypeScript
99 lines
3.2 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
fileSizeHeadroom,
|
|
headroomOf,
|
|
renderMarkdown,
|
|
statusOf,
|
|
sumTypecheckBaseline,
|
|
} from "../../../scripts/quality/baseline-headroom.mjs";
|
|
|
|
test("headroomOf: lower-is-better counts", () => {
|
|
assert.equal(headroomOf(400, 500, "down"), 0.2);
|
|
assert.equal(headroomOf(500, 500, "down"), 0);
|
|
assert.equal(headroomOf(550, 500, "down"), -0.1);
|
|
assert.equal(headroomOf(0, 0, "down"), 1);
|
|
assert.equal(headroomOf(3, 0, "down"), -1);
|
|
assert.equal(headroomOf(null as unknown as number, 5, "down"), null);
|
|
});
|
|
|
|
test("headroomOf: higher-is-better percentages", () => {
|
|
assert.ok(Math.abs(headroomOf(92.17, 76.81, "up")! - 0.2) < 0.001);
|
|
assert.equal(headroomOf(76.81, 76.81, "up"), 0);
|
|
assert.ok(headroomOf(70, 76.81, "up")! < 0);
|
|
});
|
|
|
|
test("statusOf: ok / warn / critical / unknown against the warn fraction", () => {
|
|
assert.equal(statusOf(0.2), "ok");
|
|
assert.equal(statusOf(0.1), "ok");
|
|
assert.equal(statusOf(0.05), "warn");
|
|
assert.equal(statusOf(0), "warn");
|
|
assert.equal(statusOf(-0.01), "critical");
|
|
assert.equal(statusOf(null), "unknown");
|
|
assert.equal(statusOf(0.15, 0.2), "warn");
|
|
});
|
|
|
|
test("sumTypecheckBaseline ignores notes and non-numeric entries", () => {
|
|
const sum = sumTypecheckBaseline({
|
|
"src/a.ts": { TS2345: 2, TS2339: 1 },
|
|
"src/b.ts": { TS2300: 4, note: "x" as unknown as number },
|
|
_relax_velocity: "note" as unknown as Record<string, number>,
|
|
});
|
|
assert.equal(sum, 7);
|
|
});
|
|
|
|
test("fileSizeHeadroom reports the worst frozen file and the near-cap / over counts", () => {
|
|
const frozen = { "a.ts": "1200", "b.ts": 1000, "c.ts": "500", _note: "ignored" };
|
|
const loc = (f: string) => ({ "a.ts": 1150, "b.ts": 1001, "c.ts": 100 })[f] ?? null;
|
|
const r = fileSizeHeadroom(frozen, loc, 0.1);
|
|
assert.equal(r.measured, 3);
|
|
assert.equal(r.over, 1); // b.ts 1001 > 1000
|
|
assert.equal(r.nearCap, 1); // a.ts within 10%
|
|
assert.equal(r.worst?.file, "b.ts");
|
|
assert.ok(r.worst!.headroom < 0);
|
|
});
|
|
|
|
test("renderMarkdown lists every row with its status icon and flags the bad ones", () => {
|
|
const md = renderMarkdown(
|
|
[
|
|
{
|
|
id: "deadExports",
|
|
direction: "down",
|
|
live: 416,
|
|
baseline: 500,
|
|
headroom: 0.168,
|
|
status: "ok",
|
|
note: "",
|
|
},
|
|
{
|
|
id: "fileSize",
|
|
direction: "down",
|
|
live: 1348,
|
|
baseline: 1347,
|
|
headroom: -0.001,
|
|
status: "critical",
|
|
note: "worst: g.ts",
|
|
},
|
|
{
|
|
id: "complexity",
|
|
direction: "down",
|
|
live: null,
|
|
baseline: 3218,
|
|
headroom: null,
|
|
status: "unknown",
|
|
note: "measurement unavailable",
|
|
},
|
|
],
|
|
{
|
|
policy: { since: "2026-08-30", relaxPct: 20, until: "4.0.0" },
|
|
generatedAt: "2026-08-30T12:00:00.000Z",
|
|
}
|
|
);
|
|
assert.match(md, /Velocity phase since 2026-08-30 \(relax 20%, until v4\.0\.0\)/);
|
|
assert.match(md, /`deadExports` \| 416 \| 500 \| 16\.8% \| 🟢 ok/);
|
|
assert.match(md, /`fileSize` \| 1348 \| 1347 \| -0\.1% \| 🔴 critical — worst: g\.ts/);
|
|
assert.match(md, /`complexity` \| — \| 3218 \| — \| ⚪ unknown/);
|
|
assert.match(md, /\*\*1 gate\(s\) need attention:\*\* `fileSize` \(critical\)/);
|
|
});
|