@@ -123,6 +123,30 @@ describe('lane health', () => {
123123 } ) ;
124124} ) ;
125125
126+ function git ( cwd : string , args : string [ ] , date ?: string ) : void {
127+ const stamp = date === undefined ? { } : { GIT_AUTHOR_DATE : date , GIT_COMMITTER_DATE : date } ;
128+ runCmdSync ( 'git' , args , { cwd, timeoutMs : 30_000 , env : { ...process . env , ...stamp } } ) ;
129+ }
130+
131+ /** A workflow that exists for a year, then gains a `schedule:` trigger — the transition that broke. */
132+ function repoWithLaterSchedule ( ) : { dir : string ; scheduledAt : string } {
133+ const dir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'lane-git-' ) ) ;
134+ temporaryDirs . push ( dir ) ;
135+ const workflowDir = path . join ( dir , '.github/workflows' ) ;
136+ const file = path . join ( workflowDir , 'old.yml' ) ;
137+ fs . mkdirSync ( workflowDir , { recursive : true } ) ;
138+ git ( dir , [ 'init' , '--quiet' , '--initial-branch=main' ] ) ;
139+ git ( dir , [ 'config' , 'user.email' , '[email protected] ' ] ) ; 140+ git ( dir , [ 'config' , 'user.name' , 'Lane Test' ] ) ;
141+ fs . writeFileSync ( file , 'name: Old\non:\n workflow_dispatch:\njobs: {}\n' ) ;
142+ git ( dir , [ 'add' , '.' ] ) ;
143+ git ( dir , [ 'commit' , '--quiet' , '-m' , 'add workflow' ] , '2025-01-02T03:04:05+00:00' ) ;
144+ fs . writeFileSync ( file , 'name: Old\non:\n schedule:\n - cron: "0 3 * * *"\njobs: {}\n' ) ;
145+ git ( dir , [ 'add' , '.' ] ) ;
146+ git ( dir , [ 'commit' , '--quiet' , '-m' , 'schedule it' ] , '2026-06-07T08:09:10+00:00' ) ;
147+ return { dir, scheduledAt : '2026-06-07T08:09:10+00:00' } ;
148+ }
149+
126150describe ( 'schedule registration' , ( ) => {
127151 // Anchored on the commit that introduced `schedule:`, not the workflow's creation date.
128152 it ( 'reads when a lane was scheduled out of git history' , ( ) => {
@@ -131,6 +155,29 @@ describe('schedule registration', () => {
131155 expect ( Number . isFinite ( Date . parse ( scheduled ?? '' ) ) ) . toBe ( true ) ;
132156 } ) ;
133157
158+ // The pattern must be POSIX (`[[:space:]]`, not `\s`): the shorthand matches nothing on macOS,
159+ // and a silent no-match is indistinguishable from "cannot tell" — every lane stuck pending.
160+ it ( 'finds the schedule commit, not the workflow creation commit' , ( ) => {
161+ const { dir, scheduledAt } = repoWithLaterSchedule ( ) ;
162+ const scheduled = scheduleRegisteredAt ( '.github/workflows' , 'old.yml' , dir ) ;
163+ expect ( scheduled ) . not . toBeNull ( ) ;
164+ expect ( Date . parse ( scheduled ?? '' ) ) . toBe ( Date . parse ( scheduledAt ) ) ;
165+ expect ( Date . parse ( scheduled ?? '' ) ) . toBeGreaterThan ( Date . parse ( '2025-01-02T03:04:05+00:00' ) ) ;
166+ } ) ;
167+
168+ it ( 'keeps that lane pending right after scheduling, and only alerts two cadences later' , ( ) => {
169+ const { dir, scheduledAt } = repoWithLaterSchedule ( ) ;
170+ const history = {
171+ known : true ,
172+ scheduleRegisteredAt : scheduleRegisteredAt ( '.github/workflows' , 'old.yml' , dir ) ,
173+ runs : [ ] ,
174+ } ;
175+ const scheduled = Date . parse ( scheduledAt ) ;
176+ const hour = 60 * 60 * 1000 ;
177+ expect ( laneHealth ( NIGHTLY , history , scheduled + hour ) . state ) . toBe ( 'pending' ) ;
178+ expect ( laneHealth ( NIGHTLY , history , scheduled + 49 * hour ) . state ) . toBe ( 'dark' ) ;
179+ } ) ;
180+
134181 it ( 'returns null — never a guess — for a file git knows nothing about' , ( ) => {
135182 expect ( scheduleRegisteredAt ( '.github/workflows' , 'no-such-workflow.yml' ) ) . toBeNull ( ) ;
136183 } ) ;
0 commit comments