From 5cd0224ebdcd075f175e7d111c4f92bcd190d943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Smoli=C5=84ski?= Date: Tue, 24 Nov 2026 00:01:18 +0100 Subject: [PATCH] ipal-doctor: never write first-seen dates when CI is set The CLI ignored CI (writeSeen was only !sites && !json); docs and comments already said "not in CI". shouldWriteSeen() + test. Co-Authored-By: Claude Opus 5.5 --- src/modules/doctor/cli.ts | 10 +++++++++- test/doctor.test.ts | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/modules/doctor/cli.ts b/src/modules/doctor/cli.ts index 34983e9..ccf9dd9 100644 --- a/src/modules/doctor/cli.ts +++ b/src/modules/doctor/cli.ts @@ -26,6 +26,14 @@ export const DOCTOR_USAGE = `Usage: ipal-doctor [dir] [options] Exit: 0 ok · 1 findings at or above --fail-on · 2 could not run · 3 a rule crashed Silence a rule with a reason in ipal-doctor.json — docs/doctor.md` +/** + * Whether this run stores first-seen dates in ipal-doctor.json: not with --sites or --json, and + * never when CI is set (a CI run must not change a tracked file). + */ +export function shouldWriteSeen(args: { json?: boolean; sites?: unknown }, env: Record = process.env): boolean { + return !args.sites && !args.json && !env.CI +} + const RANK: Record = { error: 3, info: 1, warning: 2 } type Args = { @@ -132,7 +140,7 @@ export async function runDoctorCli(argv: string[], { cwd = process.cwd(), log = skip: args.skip, staging: args.staging, url: args.sites ? undefined : args.url, - writeSeen: !args.sites && !args.json, + writeSeen: shouldWriteSeen(args), }), ) } diff --git a/test/doctor.test.ts b/test/doctor.test.ts index d9b13b0..37b7ba9 100644 --- a/test/doctor.test.ts +++ b/test/doctor.test.ts @@ -6,7 +6,7 @@ import { afterAll, afterEach, beforeAll, describe, expect, test, vi } from 'vite import type { DoctorConfig, DoctorReport } from '../src/modules/doctor/types.js' -import { expandSites, parseDoctorArgs, runDoctorCli } from '../src/modules/doctor/cli.js' +import { expandSites, parseDoctorArgs, runDoctorCli, shouldWriteSeen } from '../src/modules/doctor/cli.js' import { formatDriftTable, formatReport } from '../src/modules/doctor/format.js' import { bareHost, parseEnvFile, readAuditSkips } from '../src/modules/doctor/project.js' import { planSkills } from '../src/modules/doctor/rules/agents.js' @@ -452,3 +452,12 @@ describe('the reference site', () => { for (const setting of Object.values(config.rules ?? {})) {expect(setting.reason?.trim()).toBeTruthy()} }) }) + +describe('ipal-doctor: first-seen dates', () => { + test('are written only outside CI, and never with --json or --sites', () => { + expect(shouldWriteSeen({}, {})).toBe(true) + expect(shouldWriteSeen({}, { CI: 'true' })).toBe(false) + expect(shouldWriteSeen({ json: true }, {})).toBe(false) + expect(shouldWriteSeen({ sites: 'clients/*' }, {})).toBe(false) + }) +})