mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-15 12:53:31 +08:00
The repository now has a measurable PR quality path instead of a loose set of manual checks. Coverage, quarantine governance, provider smoke, desktop smoke, and workflow wiring all produce durable reports that contributors and maintainers can inspect without reconstructing terminal output. This also fixes the desktop smoke current-runtime path so browser-driven smoke runs use the desktop default active provider instead of forcing the official current model, and records that runtime decision as an artifact. Constraint: Default PR gates must remain non-live and contributor-safe while live model checks stay explicit. Constraint: Release packaging is still GitHub Actions based, so release preflight must run before the build matrix. Rejected: Make live provider or desktop smoke mandatory on every PR | secrets, quotas, and model availability are maintainer-controlled. Rejected: Let PRs lower coverage baselines in the same change | base-branch ratchet comparison must remain authoritative. Confidence: high Scope-risk: moderate Directive: Do not relax coverage or quarantine policy without a maintainer approval label and a fresh quality report. Tested: ALLOW_CLI_CORE_CHANGE=1 ALLOW_COVERAGE_BASELINE_CHANGE=1 bun run quality:gate --mode pr Tested: bun run quality:gate --mode baseline --allow-live --only provider-smoke:* --provider-model nvidia-custom:main:nvidia-custom-main --artifacts-dir /tmp/quality-gate-live-smoke Tested: bun run quality:gate --mode baseline --allow-live --only desktop-smoke:* --provider-model current:current:current-runtime --artifacts-dir /tmp/quality-gate-desktop-smoke-fixed Tested: git diff --check Not-tested: Full live release mode with multiple providers in hosted CI; provider credentials and quota remain maintainer-controlled.
111 lines
3.3 KiB
TypeScript
111 lines
3.3 KiB
TypeScript
import { describe, expect, test } from 'bun:test'
|
|
import { expiredQuarantineEntries, loadQuarantineManifest, quarantinedPathSet, renderQuarantineSummary, validateQuarantineManifest } from './quarantine'
|
|
|
|
describe('quarantine manifest', () => {
|
|
test('loads the default manifest', () => {
|
|
const manifest = loadQuarantineManifest()
|
|
expect(manifest.quarantined.length).toBeGreaterThan(0)
|
|
})
|
|
|
|
test('default manifest review dates are still active', () => {
|
|
validateQuarantineManifest(loadQuarantineManifest(), { enforceReviewDate: true })
|
|
})
|
|
|
|
test('exposes quarantined paths as a set', () => {
|
|
const paths = quarantinedPathSet()
|
|
expect(paths.has('src/server/__tests__/providers-real.test.ts')).toBe(true)
|
|
})
|
|
|
|
test('rejects duplicate ids', () => {
|
|
expect(() => validateQuarantineManifest({
|
|
quarantined: [
|
|
{
|
|
id: 'duplicate',
|
|
path: 'a.test.ts',
|
|
reason: 'test',
|
|
owner: 'maintainers',
|
|
reviewAfter: '2026-06-01',
|
|
exitCriteria: 'make deterministic',
|
|
},
|
|
{
|
|
id: 'duplicate',
|
|
path: 'b.test.ts',
|
|
reason: 'test',
|
|
owner: 'maintainers',
|
|
reviewAfter: '2026-06-01',
|
|
exitCriteria: 'make deterministic',
|
|
},
|
|
],
|
|
})).toThrow('duplicate quarantine id')
|
|
})
|
|
|
|
test('requires exit criteria and valid review dates', () => {
|
|
expect(() => validateQuarantineManifest({
|
|
quarantined: [
|
|
{
|
|
id: 'missing-exit',
|
|
path: 'a.test.ts',
|
|
reason: 'test',
|
|
owner: 'maintainers',
|
|
reviewAfter: '2026-06-01',
|
|
exitCriteria: '',
|
|
},
|
|
],
|
|
})).toThrow('invalid quarantine entry')
|
|
|
|
expect(() => validateQuarantineManifest({
|
|
quarantined: [
|
|
{
|
|
id: 'bad-date',
|
|
path: 'a.test.ts',
|
|
reason: 'test',
|
|
owner: 'maintainers',
|
|
reviewAfter: 'soon',
|
|
exitCriteria: 'make deterministic',
|
|
},
|
|
],
|
|
})).toThrow('invalid quarantine reviewAfter date')
|
|
})
|
|
|
|
test('detects expired review dates when enforcement is requested', () => {
|
|
const manifest = {
|
|
quarantined: [
|
|
{
|
|
id: 'expired',
|
|
path: 'a.test.ts',
|
|
reason: 'test',
|
|
owner: 'maintainers',
|
|
reviewAfter: '2026-01-01',
|
|
exitCriteria: 'make deterministic',
|
|
},
|
|
],
|
|
}
|
|
|
|
expect(expiredQuarantineEntries(manifest, new Date('2026-05-06T00:00:00.000Z')).map((entry) => entry.id)).toEqual(['expired'])
|
|
expect(() => validateQuarantineManifest(manifest, {
|
|
enforceReviewDate: true,
|
|
asOf: new Date('2026-05-06T00:00:00.000Z'),
|
|
})).toThrow('expired quarantine entries require review')
|
|
})
|
|
|
|
test('renders a compact review summary', () => {
|
|
const manifest = {
|
|
quarantined: [
|
|
{
|
|
id: 'expired',
|
|
path: 'a.test.ts',
|
|
reason: 'test',
|
|
owner: 'maintainers',
|
|
reviewAfter: '2026-01-01',
|
|
exitCriteria: 'make deterministic',
|
|
},
|
|
],
|
|
}
|
|
|
|
const summary = renderQuarantineSummary(manifest, new Date('2026-05-06T00:00:00.000Z'))
|
|
expect(summary).toContain('Entries: 1')
|
|
expect(summary).toContain('Expired: 1')
|
|
expect(summary).toContain('expired (a.test.ts, reviewAfter=2026-01-01)')
|
|
})
|
|
})
|