bareloop 0.54.0 → 0.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/bareloop.context.md +73 -12
  3. package/package.json +3 -3
  4. package/src/authorflow.js +148 -46
  5. package/src/authoring.js +21 -4
  6. package/src/authorjob.js +82 -3
  7. package/src/authorreadout.js +20 -3
  8. package/src/authorrun.js +1 -1
  9. package/src/authorscout.js +9 -6
  10. package/src/bridges.js +4 -3
  11. package/src/cardschedule.js +42 -0
  12. package/src/carrystore.js +1 -1
  13. package/src/checkpick.js +576 -0
  14. package/src/checksuggest.js +28 -0
  15. package/src/checkwords.js +25 -0
  16. package/src/cli.js +1 -1
  17. package/src/config.js +24 -1
  18. package/src/declaredclose.js +1 -1
  19. package/src/destpoint.js +149 -0
  20. package/src/draftspend.js +39 -0
  21. package/src/factwords.js +14 -1
  22. package/src/job.js +81 -1
  23. package/src/jobblock.js +9 -0
  24. package/src/labelscan.js +11 -0
  25. package/src/launcher.js +10 -6
  26. package/src/learn.js +6 -4
  27. package/src/mcpchecks.js +52 -0
  28. package/src/mcppick.js +36 -0
  29. package/src/mcpsources.js +77 -0
  30. package/src/mcpuse.js +97 -0
  31. package/src/natural.js +23 -0
  32. package/src/pagemap.js +5 -2
  33. package/src/panel/authorroutes.js +90 -15
  34. package/src/panel/authorsession.js +183 -21
  35. package/src/panel/index.html +686 -26
  36. package/src/panel/jobgrid.js +117 -0
  37. package/src/panel/jobplan.js +31 -15
  38. package/src/panel/scheduler.js +80 -13
  39. package/src/panel/schedules.js +189 -28
  40. package/src/panel/schedulestart.js +44 -13
  41. package/src/panel/server.js +438 -33
  42. package/src/panel/settingsroutes.js +133 -3
  43. package/src/panel/status.js +22 -2
  44. package/src/panel/tickets.js +44 -0
  45. package/src/pickrecord.js +145 -0
  46. package/src/plan.js +31 -2
  47. package/src/planrun.js +71 -15
  48. package/src/prcheckout.js +259 -0
  49. package/src/readshim.js +3 -2
  50. package/src/replay.js +6 -0
  51. package/src/reuse.js +3 -3
  52. package/src/revises.js +56 -0
  53. package/src/rubricstep.js +62 -16
  54. package/src/run.js +10 -1
  55. package/src/runexport.js +2 -0
  56. package/src/runlist.js +3 -2
  57. package/src/schedulewords.js +46 -4
  58. package/src/source.js +81 -7
  59. package/src/stepmcp.js +86 -0
  60. package/src/ticket.js +113 -0
  61. package/src/ticketfilter.js +76 -0
  62. package/src/ticketlabels.js +79 -0
  63. package/src/ticketmcp.js +111 -0
  64. package/src/ticketnext.js +35 -0
  65. package/src/ticketrepo.js +98 -0
  66. package/src/ticketschedule.js +32 -0
  67. package/src/ticketshape.js +45 -0
  68. package/src/tools.js +9 -0
  69. package/src/trigger.js +14 -2
  70. package/src/triggerclock.js +7 -3
  71. package/src/triggerfiles.js +19 -11
  72. package/src/triggertickets.js +244 -0
  73. package/src/u-readout.js +2 -2
  74. package/src/userrun.js +146 -10
  75. package/src/validate.js +3 -1
  76. package/src/worktree.js +43 -1
  77. package/types/authorflow.d.ts +128 -28
  78. package/types/authorjob.d.ts +16 -3
  79. package/types/authorreadout.d.ts +9 -2
  80. package/types/authorscout.d.ts +4 -2
  81. package/types/bridges.d.ts +4 -3
  82. package/types/cardschedule.d.ts +24 -0
  83. package/types/checkpick.d.ts +297 -0
  84. package/types/checksuggest.d.ts +30 -0
  85. package/types/checkwords.d.ts +14 -0
  86. package/types/config.d.ts +7 -0
  87. package/types/destpoint.d.ts +87 -0
  88. package/types/draftspend.d.ts +16 -0
  89. package/types/factwords.d.ts +7 -0
  90. package/types/job.d.ts +13 -0
  91. package/types/jobblock.d.ts +9 -0
  92. package/types/labelscan.d.ts +7 -0
  93. package/types/launcher.d.ts +7 -2
  94. package/types/mcpchecks.d.ts +8 -0
  95. package/types/mcppick.d.ts +33 -0
  96. package/types/mcpsources.d.ts +51 -0
  97. package/types/mcpuse.d.ts +15 -0
  98. package/types/natural.d.ts +2 -0
  99. package/types/pagemap.d.ts +2 -1
  100. package/types/panel/authorroutes.d.ts +11 -2
  101. package/types/panel/authorsession.d.ts +58 -3
  102. package/types/panel/jobgrid.d.ts +405 -0
  103. package/types/panel/jobplan.d.ts +10 -4
  104. package/types/panel/scheduler.d.ts +7 -2
  105. package/types/panel/schedules.d.ts +124 -4
  106. package/types/panel/schedulestart.d.ts +21 -3
  107. package/types/panel/server.d.ts +427 -6
  108. package/types/panel/settingsroutes.d.ts +4 -2
  109. package/types/panel/status.d.ts +16 -2
  110. package/types/panel/tickets.d.ts +61 -0
  111. package/types/pickrecord.d.ts +88 -0
  112. package/types/plan.d.ts +1 -0
  113. package/types/prcheckout.d.ts +151 -0
  114. package/types/readshim.d.ts +4 -3
  115. package/types/replay.d.ts +3 -0
  116. package/types/reuse.d.ts +2 -2
  117. package/types/revises.d.ts +23 -0
  118. package/types/rubricstep.d.ts +14 -5
  119. package/types/run.d.ts +18 -1
  120. package/types/runlist.d.ts +6 -3
  121. package/types/schedulewords.d.ts +29 -2
  122. package/types/source.d.ts +40 -4
  123. package/types/stepmcp.d.ts +40 -0
  124. package/types/ticket.d.ts +114 -0
  125. package/types/ticketfilter.d.ts +34 -0
  126. package/types/ticketlabels.d.ts +44 -0
  127. package/types/ticketmcp.d.ts +84 -0
  128. package/types/ticketnext.d.ts +33 -0
  129. package/types/ticketrepo.d.ts +118 -0
  130. package/types/ticketschedule.d.ts +21 -0
  131. package/types/ticketshape.d.ts +37 -0
  132. package/types/tools.d.ts +1 -0
  133. package/types/trigger.d.ts +9 -1
  134. package/types/triggerclock.d.ts +6 -2
  135. package/types/triggerfiles.d.ts +13 -5
  136. package/types/triggertickets.d.ts +110 -0
  137. package/types/userrun.d.ts +50 -0
  138. package/types/validate.d.ts +1 -0
  139. package/types/worktree.d.ts +19 -0
@@ -1,6 +1,3 @@
1
- /** @typedef {{name: string, cls: 'machine check'|'judge'|null}} PlanCheck */
2
- /** @typedef {{n: number, text: string, rule: string, rules: string[], checks: PlanCheck[], refused: string[], always?: string[]}} PlanLine */
3
- /** @typedef {{lines: PlanLine[], loose: PlanCheck[], notChecked: string[], readNotes: string[], alwaysOn: string[], older: boolean, goal?: string}} JobPlan */
4
1
  /**
5
2
  * `machine check` for a kind a command decides, `judge` for one that needs judgement; `null` for a stage whose kind is
6
3
  * unknown (a hand-written command close has no kind: it is a command, so a machine check).
@@ -27,7 +24,7 @@ export function planFromSpec(spec: any): JobPlan;
27
24
  * The plan of the confirm turn, before anything is drafted: the person's own job lines, the model's checks under the
28
25
  * line each names, its own "not checked" words, and the real protections (code-owned) as "Always checked".
29
26
  * @param {{n: number, text: string, rule: string, rules?: string[]}[]|null|undefined} jobLines
30
- * @param {{checkItems?: {text: string, fromLine: number[]|null}[], checks?: string[], notChecked?: string[], protections?: string[], signedFacts?: string[]}} plan
27
+ * @param {{checkItems?: {text: string, fromLine: number[]|null, by?: 'agent'|'you'|null}[], checks?: string[], notChecked?: string[], protections?: string[], signedFacts?: string[], ticketFilter?: any, picked?: {line: number, text: string}[]}} plan
31
28
  * `signedFacts` = the names of the facts the look signs (so an S1 copy of a signed fact reads as a note, not Not checked)
32
29
  * @returns {JobPlan}
33
30
  */
@@ -40,15 +37,22 @@ export function planFromConfirm(jobLines: {
40
37
  checkItems?: {
41
38
  text: string;
42
39
  fromLine: number[] | null;
40
+ by?: "agent" | "you" | null;
43
41
  }[];
44
42
  checks?: string[];
45
43
  notChecked?: string[];
46
44
  protections?: string[];
47
45
  signedFacts?: string[];
46
+ ticketFilter?: any;
47
+ picked?: {
48
+ line: number;
49
+ text: string;
50
+ }[];
48
51
  }): JobPlan;
49
52
  export type PlanCheck = {
50
53
  name: string;
51
54
  cls: "machine check" | "judge" | null;
55
+ by?: "agent" | "you" | null;
52
56
  };
53
57
  export type PlanLine = {
54
58
  n: number;
@@ -58,6 +62,7 @@ export type PlanLine = {
58
62
  checks: PlanCheck[];
59
63
  refused: string[];
60
64
  always?: string[];
65
+ picked?: string[];
61
66
  };
62
67
  export type JobPlan = {
63
68
  lines: PlanLine[];
@@ -67,4 +72,5 @@ export type JobPlan = {
67
72
  alwaysOn: string[];
68
73
  older: boolean;
69
74
  goal?: string;
75
+ ticketFilter?: string;
70
76
  };
@@ -1,13 +1,17 @@
1
1
  /**
2
- * @param {{ door: ReturnType<typeof import('./schedules.js').createScheduleDoor>, now?: () => number, intervalMs?: number }} opts
3
- * `intervalMs` 0 = no timer (a test drives `tick`).
2
+ * @param {{ door: ReturnType<typeof import('./schedules.js').createScheduleDoor>, now?: () => number, intervalMs?: number, look?: typeof lookTickets, mcpConfig?: string }} opts
3
+ * `intervalMs` 0 = no timer (a test drives `tick`). `look` / `mcpConfig` = the ticket look and the MCP config file it reads (tests inject them; default the real look over the person's own config).
4
4
  */
5
5
  export function createScheduler(opts: {
6
6
  door: ReturnType<typeof import("./schedules.js").createScheduleDoor>;
7
7
  now?: () => number;
8
8
  intervalMs?: number;
9
+ look?: typeof lookTickets;
10
+ mcpConfig?: string;
9
11
  }): {
10
12
  tick: () => Promise<void>;
13
+ /** resolves when every ticket look now out has been written to its ledger (a test awaits it; the timer never does) */
14
+ settled(): Promise<void>;
11
15
  /** Start the real timer (idempotent). */
12
16
  start(): void;
13
17
  /** Stop it (idempotent). The server's close calls this. */
@@ -15,3 +19,4 @@ export function createScheduler(opts: {
15
19
  /** whether the real timer is running (a test reads this) */
16
20
  readonly running: boolean;
17
21
  };
22
+ import { lookTickets } from '../triggertickets.js';
@@ -14,7 +14,7 @@ export function procStartMs(pid: number, read?: (path: string) => string): numbe
14
14
  */
15
15
  export function runnerAlive(row: any, nowMs: number): boolean;
16
16
  /**
17
- * @typedef {{runid: string, outcome: string|null, spec: any, records: any[]}} JobRun
17
+ * @typedef {{runid: string, outcome: string|null, spec: any, records: any[], ticket?: number}} JobRun
18
18
  * @typedef {{job: string, trigger: import('../trigger.js').Trigger, spec: any, specHash: string, workflowKey: string,
19
19
  * originRunid: string, inputsText: string, destination?: string, signedBy: string, signedAt: string}} Schedule
20
20
  */
@@ -67,7 +67,7 @@ export function createScheduleDoor(deps: {
67
67
  * `key|outcome|why` (read back from disk, so a restart does not repeat it). RULED 2026-10-14: a busy, monthly or refused
68
68
  * fire consumes NOTHING, so the next tick tries again; a spawn error after `beforeSpawn` writes a `released` row (bounded).
69
69
  * @param {string} job
70
- * @param {{kind: 'clock', slot: number, catchUp: boolean, missed: number} | {kind: 'file', path: string, sha: string, size?: number}} cause
70
+ * @param {{kind: 'clock', slot: number, catchUp: boolean, missed: number} | {kind: 'file', path: string, sha: string, size?: number} | {kind: 'ticket', number: number, sha: string, why?: string, anyway?: boolean}} cause
71
71
  * @param {{beforeSpawn?: () => void, busy?: boolean}} [hooks] `busy` = the scheduler's one read of the run list this tick
72
72
  * @returns {Promise<{outcome: 'busy'|'monthly-exhausted'|'refused'|'started', why?: string, told: boolean, sessionId?: string}>}
73
73
  */
@@ -81,6 +81,12 @@ export function createScheduleDoor(deps: {
81
81
  path: string;
82
82
  sha: string;
83
83
  size?: number;
84
+ } | {
85
+ kind: "ticket";
86
+ number: number;
87
+ sha: string;
88
+ why?: string;
89
+ anyway?: boolean;
84
90
  }, hooks?: {
85
91
  beforeSpawn?: () => void;
86
92
  busy?: boolean;
@@ -90,7 +96,41 @@ export function createScheduleDoor(deps: {
90
96
  told: boolean;
91
97
  sessionId?: string;
92
98
  }>;
93
- greenFor: (job: string) => {
99
+ /**
100
+ * R7, am3 (fwd M13 am3): "Run it anyway" on a ticket while the job's ticket schedule is still OFF (signed with the job, waiting for its first green run): start that ticket's run at
101
+ * once, by hand, with the job's normal cap, after the same busy / monthly / would-accept checks a fire makes. `null` = not this door's case (no ticket schedule, or it is on: the queue
102
+ * takes it, R8). Else `{ok, say}`; a refusal starts nothing and spends $0. It writes NO ledger row: a skipped run never arms the schedule, a green one does (`armFor`).
103
+ * `fromRun` (am3, no ticket schedule at all): the skipped run whose saved signed job is started instead of a schedule's.
104
+ * @param {{job: string, number: number, fromRun?: string}} a
105
+ * @returns {Promise<{ok: boolean, say: string}|null>}
106
+ */
107
+ startAnyway({ job, number, fromRun }: {
108
+ job: string;
109
+ number: number;
110
+ fromRun?: string;
111
+ }): Promise<{
112
+ ok: boolean;
113
+ say: string;
114
+ } | null>;
115
+ /**
116
+ * R8 (piece 4, `POST /api/author/ticket-anyway`): the ONE door of "Run it anyway" once the person has given a reason (the route checks it). A ticket schedule that is still OFF starts that
117
+ * ticket's run at once ({@link startAnyway}, by hand, no row); one that is ON takes ONE `arrived` row with the reason and `anyway: true` ({@link recordAnyway}), and the queue starts it
118
+ * with `--anyway` under the job's normal cap. A job with NO ticket schedule (am3: for a first ticket this is the only way to run it) starts at once from the skipped run's own saved signed job
119
+ * (`runid`, the grid's skipped row, through the one `startFrom` and the one starter); with no readable job there, or no `runid`, it is refused in words and nothing is written.
120
+ * @param {{job: string, number: number, reason: string, runid?: string}} a
121
+ * @returns {Promise<{ok: boolean, say: string, started?: boolean}>}
122
+ */
123
+ arriveAnyway({ job, number, reason, runid }: {
124
+ job: string;
125
+ number: number;
126
+ reason: string;
127
+ runid?: string;
128
+ }): Promise<{
129
+ ok: boolean;
130
+ say: string;
131
+ started?: boolean;
132
+ }>;
133
+ greenFor: (job: string, skip?: Set<string>) => {
94
134
  ok: true;
95
135
  run: JobRun;
96
136
  key: string;
@@ -102,7 +142,8 @@ export function createScheduleDoor(deps: {
102
142
  baseline?: boolean;
103
143
  }) => {
104
144
  armed: boolean;
105
- already: boolean;
145
+ already?: boolean;
146
+ waiting?: boolean;
106
147
  };
107
148
  readSchedule: (job: string) => Schedule | null;
108
149
  ledgerOf: (job: string) => string;
@@ -168,6 +209,26 @@ export function createScheduleDoor(deps: {
168
209
  cancelled?: undefined;
169
210
  };
170
211
  };
212
+ /**
213
+ * R7 (piece 9, hamr: schedule exactly like fwd): the New job card's Sign & run signs the schedule WITH the job, written OFF. It writes `schedule.json`, a `signed` row and a `waiting`
214
+ * row that remembers the runs the job already had (`before`): only a run that began after this turns the schedule on (`armFor`, the one turn-on), and a skipped run never does.
215
+ * Nothing looks or fires while it waits. $0. A refusal names why and writes nothing. The job is the one just signed, so a job that already has a schedule is refused (the two-click door edits it).
216
+ * @param {{spec: any, specHash: string, trigger: unknown, inputsText: string, destination?: string|null}} o `spec` = the signed spec WITH its `trigger`; `specHash` = the hash the person signed (it must be the spec's own)
217
+ * @returns {{ok: true, hash: string}|{ok: false, say: string}}
218
+ */
219
+ signWithJob(o: {
220
+ spec: any;
221
+ specHash: string;
222
+ trigger: unknown;
223
+ inputsText: string;
224
+ destination?: string | null;
225
+ }): {
226
+ ok: true;
227
+ hash: string;
228
+ } | {
229
+ ok: false;
230
+ say: string;
231
+ };
171
232
  /** Cancel a job's schedule, never refused. @param {string} job @returns {boolean} there was one */
172
233
  cancel(job: string): boolean;
173
234
  /** Every job with a schedule.json: `{job, dir, schedule}`. One readdir; nothing else read when there is none. */
@@ -187,10 +248,12 @@ export function createScheduleDoor(deps: {
187
248
  trigger: null;
188
249
  armed: boolean;
189
250
  armedAt: null;
251
+ waiting: boolean;
190
252
  nextSlotMs: null;
191
253
  lastOutcome: null;
192
254
  retryInMs: null;
193
255
  gaveUp: null;
256
+ lookProblem: null;
194
257
  job: string;
195
258
  hasGreen: boolean;
196
259
  refusal: string | null;
@@ -199,10 +262,15 @@ export function createScheduleDoor(deps: {
199
262
  trigger: import("../trigger.js").Trigger;
200
263
  armed: boolean;
201
264
  armedAt: number | null | undefined;
265
+ waiting: boolean;
202
266
  nextSlotMs: number | null;
203
267
  lastOutcome: import("../triggerledger.js").LedgerRow | null;
204
268
  retryInMs: number | null;
205
269
  gaveUp: import("../triggerledger.js").LedgerRow | null;
270
+ lookProblem: {
271
+ at: number;
272
+ why: string;
273
+ } | null;
206
274
  job: string;
207
275
  hasGreen: boolean;
208
276
  refusal: string | null;
@@ -212,20 +280,29 @@ export function createScheduleDoor(deps: {
212
280
  trigger: null;
213
281
  armed: boolean;
214
282
  armedAt: null;
283
+ waiting: boolean;
215
284
  nextSlotMs: null;
216
285
  lastOutcome: null;
217
286
  retryInMs: null;
218
287
  gaveUp: null;
288
+ lookProblem: null;
219
289
  } | {
220
290
  schedule: Schedule;
221
291
  trigger: import("../trigger.js").Trigger;
222
292
  armed: boolean;
223
293
  armedAt: number | null | undefined;
294
+ waiting: boolean;
224
295
  nextSlotMs: number | null;
225
296
  lastOutcome: import("../triggerledger.js").LedgerRow | null;
226
297
  retryInMs: number | null;
227
298
  gaveUp: import("../triggerledger.js").LedgerRow | null;
299
+ lookProblem: {
300
+ at: number;
301
+ why: string;
302
+ } | null;
228
303
  };
304
+ /** is this job's schedule signed with its job and still off? (the Audit and Job tab read it) @param {string} job */
305
+ isWaiting(job: string): boolean;
229
306
  userHome: string;
230
307
  /**
231
308
  * What the Run tab shows of a job's schedule (A.12: one read of the schedule files and the ledger; the green gate is
@@ -260,18 +337,32 @@ export function createScheduleDoor(deps: {
260
337
  weekly: "Every <day> at HH:MM";
261
338
  'file-updated': "When <file> is updated";
262
339
  'new-file': "When a new file arrives in <folder>";
340
+ 'new-ticket': "When a new ticket arrives in <input>";
263
341
  }>;
264
342
  gaveUpPill: "Check";
265
343
  problemNext: "next: fix it in Cancel / modify schedule";
266
344
  monthNext: "next: raise the limit in Settings, or it starts on the 1st";
267
345
  acceptWaiting: "waiting for your Accept (the next run does not wait)";
346
+ waiting: "Schedule waiting for a green run";
268
347
  scheduleGroup: "schedule";
269
348
  notGreen: "This job has not had a good run yet. Run it by hand and get it right first; then you can set when it runs. A rubric job also needs your Accept once. Nothing was changed.";
349
+ card: Readonly<{
350
+ label: "Schedule";
351
+ options: Readonly<{
352
+ hand: "By hand";
353
+ 'new-ticket': "When a new ticket arrives";
354
+ daily: "Every day at HH:MM";
355
+ }>;
356
+ hint: "off until the first green run, then turns on";
357
+ rubricHint: "off until the first green run is accepted, then turns on";
358
+ ticketHint: "the first run reads the newest ticket at the time it starts; older tickets never run";
359
+ }>;
270
360
  stale: "What you were shown is not what is on the card now. Nothing was signed. Look again, then sign.";
271
361
  }>;
272
362
  text?: undefined;
273
363
  next?: undefined;
274
364
  nextRed?: undefined;
365
+ waiting?: undefined;
275
366
  lastRow?: undefined;
276
367
  problem?: undefined;
277
368
  nextWords?: undefined;
@@ -299,19 +390,33 @@ export function createScheduleDoor(deps: {
299
390
  weekly: "Every <day> at HH:MM";
300
391
  'file-updated': "When <file> is updated";
301
392
  'new-file': "When a new file arrives in <folder>";
393
+ 'new-ticket': "When a new ticket arrives in <input>";
302
394
  }>;
303
395
  gaveUpPill: "Check";
304
396
  problemNext: "next: fix it in Cancel / modify schedule";
305
397
  monthNext: "next: raise the limit in Settings, or it starts on the 1st";
306
398
  acceptWaiting: "waiting for your Accept (the next run does not wait)";
399
+ waiting: "Schedule waiting for a green run";
307
400
  scheduleGroup: "schedule";
308
401
  notGreen: "This job has not had a good run yet. Run it by hand and get it right first; then you can set when it runs. A rubric job also needs your Accept once. Nothing was changed.";
402
+ card: Readonly<{
403
+ label: "Schedule";
404
+ options: Readonly<{
405
+ hand: "By hand";
406
+ 'new-ticket': "When a new ticket arrives";
407
+ daily: "Every day at HH:MM";
408
+ }>;
409
+ hint: "off until the first green run, then turns on";
410
+ rubricHint: "off until the first green run is accepted, then turns on";
411
+ ticketHint: "the first run reads the newest ticket at the time it starts; older tickets never run";
412
+ }>;
309
413
  stale: "What you were shown is not what is on the card now. Nothing was signed. Look again, then sign.";
310
414
  }>;
311
415
  fromRunid: string;
312
416
  text: string | null;
313
417
  next: string;
314
418
  nextRed: boolean;
419
+ waiting: boolean;
315
420
  lastRow: import("../triggerledger.js").LedgerRow | null;
316
421
  problem: boolean;
317
422
  nextWords: string;
@@ -328,6 +433,7 @@ export function createScheduleDoor(deps: {
328
433
  trigger: import("../trigger.js").Trigger | null;
329
434
  now: string | null;
330
435
  refusal: string | null;
436
+ ticketInputs: string[];
331
437
  words: Readonly<{
332
438
  byHand: "By hand";
333
439
  cancelSchedule: "Cancel schedule";
@@ -348,13 +454,26 @@ export function createScheduleDoor(deps: {
348
454
  weekly: "Every <day> at HH:MM";
349
455
  'file-updated': "When <file> is updated";
350
456
  'new-file': "When a new file arrives in <folder>";
457
+ 'new-ticket': "When a new ticket arrives in <input>";
351
458
  }>;
352
459
  gaveUpPill: "Check";
353
460
  problemNext: "next: fix it in Cancel / modify schedule";
354
461
  monthNext: "next: raise the limit in Settings, or it starts on the 1st";
355
462
  acceptWaiting: "waiting for your Accept (the next run does not wait)";
463
+ waiting: "Schedule waiting for a green run";
356
464
  scheduleGroup: "schedule";
357
465
  notGreen: "This job has not had a good run yet. Run it by hand and get it right first; then you can set when it runs. A rubric job also needs your Accept once. Nothing was changed.";
466
+ card: Readonly<{
467
+ label: "Schedule";
468
+ options: Readonly<{
469
+ hand: "By hand";
470
+ 'new-ticket': "When a new ticket arrives";
471
+ daily: "Every day at HH:MM";
472
+ }>;
473
+ hint: "off until the first green run, then turns on";
474
+ rubricHint: "off until the first green run is accepted, then turns on";
475
+ ticketHint: "the first run reads the newest ticket at the time it starts; older tickets never run";
476
+ }>;
358
477
  stale: "What you were shown is not what is on the card now. Nothing was signed. Look again, then sign.";
359
478
  }>;
360
479
  };
@@ -397,6 +516,7 @@ export type JobRun = {
397
516
  outcome: string | null;
398
517
  spec: any;
399
518
  records: any[];
519
+ ticket?: number;
400
520
  };
401
521
  export type Schedule = {
402
522
  job: string;
@@ -3,7 +3,8 @@
3
3
  * field must be deep-equal and the workflow key unchanged (F.4): the person signed the SCHEDULE, each fire's hash is
4
4
  * derived by code. A clock fire's spec equals the signed spec byte for byte (same hash).
5
5
  * @param {{spec: any, specHash: string, workflowKey: string}} schedule
6
- * @param {{kind: 'clock'}|{kind: 'file', path: string}} cause
6
+ * A TICKET fire leaves the spec UNCHANGED (hash equal, like a clock fire): the ticket number is per run, never signed, and rides on argv (`--ticket N`).
7
+ * @param {{kind: 'clock'}|{kind: 'file', path: string}|{kind: 'ticket'}} cause
7
8
  * @returns {{ok: true, spec: any, hash: string}|{ok: false, why: string}}
8
9
  */
9
10
  export function perFireSpec(schedule: {
@@ -15,6 +16,8 @@ export function perFireSpec(schedule: {
15
16
  } | {
16
17
  kind: "file";
17
18
  path: string;
19
+ } | {
20
+ kind: "ticket";
18
21
  }): {
19
22
  ok: true;
20
23
  spec: any;
@@ -55,7 +58,7 @@ export function createStarter(deps: {
55
58
  /**
56
59
  * Cheap, $0, no copy, no session. `{ok: true}` or `{ok: false, why}` (words).
57
60
  * @param {string} job
58
- * @param {{kind: 'clock'} | {kind: 'file', path: string, sha: string}} cause
61
+ * @param {{kind: 'clock'} | {kind: 'file', path: string, sha: string} | {kind: 'ticket', number: number, sha: string, byHand?: boolean, anyway?: boolean, fromRun?: string}} cause `byHand` (R7, am3) = "Run it anyway" while the schedule is still off: no good run exists yet to read the saved job from
59
62
  * @returns {{ok: true}|{ok: false, why: string}}
60
63
  */
61
64
  wouldAccept(job: string, cause: {
@@ -64,6 +67,13 @@ export function createStarter(deps: {
64
67
  kind: "file";
65
68
  path: string;
66
69
  sha: string;
70
+ } | {
71
+ kind: "ticket";
72
+ number: number;
73
+ sha: string;
74
+ byHand?: boolean;
75
+ anyway?: boolean;
76
+ fromRun?: string;
67
77
  }): {
68
78
  ok: true;
69
79
  } | {
@@ -73,7 +83,8 @@ export function createStarter(deps: {
73
83
  /**
74
84
  * Start the run. Never throws. `consumed` says whether `beforeSpawn` ran, so the caller knows whether a `released` row is owed.
75
85
  * @param {string} job
76
- * @param {{kind: 'clock', slot: number, catchUp: boolean, missed: number} | {kind: 'file', path: string, sha: string}} cause
86
+ * @param {{kind: 'clock', slot: number, catchUp: boolean, missed: number} | {kind: 'file', path: string, sha: string} | {kind: 'ticket', number: number, sha: string, byHand?: boolean, anyway?: boolean, fromRun?: string}} cause
87
+ * `byHand` (R7, am3): the person's own "Run it anyway" while the schedule is still off - the same path as Sign & run (no review door, no `trigger.json`, `--anyway`), the job's normal cap, no ledger row
77
88
  * @param {{beforeSpawn?: () => void}} [hooks]
78
89
  * @returns {Promise<{ok: true, sessionId: string, specHash: string, consumed: true}|{ok: false, why: string, consumed: boolean, installNeeded?: true}>}
79
90
  */
@@ -86,6 +97,13 @@ export function createStarter(deps: {
86
97
  kind: "file";
87
98
  path: string;
88
99
  sha: string;
100
+ } | {
101
+ kind: "ticket";
102
+ number: number;
103
+ sha: string;
104
+ byHand?: boolean;
105
+ anyway?: boolean;
106
+ fromRun?: string;
89
107
  }, hooks?: {
90
108
  beforeSpawn?: () => void;
91
109
  }): Promise<{