bareloop 0.54.1 → 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 (130) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/bareloop.context.md +65 -6
  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/cardschedule.js +42 -0
  11. package/src/checkpick.js +576 -0
  12. package/src/checksuggest.js +28 -0
  13. package/src/checkwords.js +25 -0
  14. package/src/cli.js +1 -1
  15. package/src/config.js +24 -1
  16. package/src/declaredclose.js +1 -1
  17. package/src/destpoint.js +149 -0
  18. package/src/draftspend.js +39 -0
  19. package/src/factwords.js +14 -1
  20. package/src/job.js +81 -1
  21. package/src/jobblock.js +9 -0
  22. package/src/labelscan.js +11 -0
  23. package/src/launcher.js +3 -2
  24. package/src/mcpchecks.js +52 -0
  25. package/src/mcppick.js +36 -0
  26. package/src/mcpsources.js +77 -0
  27. package/src/mcpuse.js +97 -0
  28. package/src/natural.js +23 -0
  29. package/src/pagemap.js +5 -2
  30. package/src/panel/authorroutes.js +90 -15
  31. package/src/panel/authorsession.js +183 -21
  32. package/src/panel/index.html +686 -26
  33. package/src/panel/jobgrid.js +117 -0
  34. package/src/panel/jobplan.js +31 -15
  35. package/src/panel/scheduler.js +80 -13
  36. package/src/panel/schedules.js +189 -28
  37. package/src/panel/schedulestart.js +44 -13
  38. package/src/panel/server.js +419 -32
  39. package/src/panel/settingsroutes.js +133 -3
  40. package/src/panel/status.js +19 -1
  41. package/src/panel/tickets.js +44 -0
  42. package/src/pickrecord.js +145 -0
  43. package/src/plan.js +31 -2
  44. package/src/planrun.js +71 -15
  45. package/src/prcheckout.js +259 -0
  46. package/src/readshim.js +3 -2
  47. package/src/revises.js +56 -0
  48. package/src/rubricstep.js +62 -16
  49. package/src/run.js +10 -1
  50. package/src/runexport.js +2 -0
  51. package/src/runlist.js +3 -2
  52. package/src/schedulewords.js +46 -4
  53. package/src/source.js +81 -7
  54. package/src/stepmcp.js +86 -0
  55. package/src/ticket.js +113 -0
  56. package/src/ticketfilter.js +76 -0
  57. package/src/ticketlabels.js +79 -0
  58. package/src/ticketmcp.js +111 -0
  59. package/src/ticketnext.js +35 -0
  60. package/src/ticketrepo.js +98 -0
  61. package/src/ticketschedule.js +32 -0
  62. package/src/ticketshape.js +45 -0
  63. package/src/tools.js +9 -0
  64. package/src/trigger.js +14 -2
  65. package/src/triggerclock.js +7 -3
  66. package/src/triggerfiles.js +19 -11
  67. package/src/triggertickets.js +244 -0
  68. package/src/userrun.js +145 -9
  69. package/src/validate.js +3 -1
  70. package/src/worktree.js +43 -1
  71. package/types/authorflow.d.ts +128 -28
  72. package/types/authorjob.d.ts +16 -3
  73. package/types/authorreadout.d.ts +9 -2
  74. package/types/authorscout.d.ts +4 -2
  75. package/types/cardschedule.d.ts +24 -0
  76. package/types/checkpick.d.ts +297 -0
  77. package/types/checksuggest.d.ts +30 -0
  78. package/types/checkwords.d.ts +14 -0
  79. package/types/config.d.ts +7 -0
  80. package/types/destpoint.d.ts +87 -0
  81. package/types/draftspend.d.ts +16 -0
  82. package/types/factwords.d.ts +7 -0
  83. package/types/job.d.ts +13 -0
  84. package/types/jobblock.d.ts +9 -0
  85. package/types/labelscan.d.ts +7 -0
  86. package/types/launcher.d.ts +2 -2
  87. package/types/mcpchecks.d.ts +8 -0
  88. package/types/mcppick.d.ts +33 -0
  89. package/types/mcpsources.d.ts +51 -0
  90. package/types/mcpuse.d.ts +15 -0
  91. package/types/natural.d.ts +2 -0
  92. package/types/pagemap.d.ts +2 -1
  93. package/types/panel/authorroutes.d.ts +11 -2
  94. package/types/panel/authorsession.d.ts +58 -3
  95. package/types/panel/jobgrid.d.ts +405 -0
  96. package/types/panel/jobplan.d.ts +10 -4
  97. package/types/panel/scheduler.d.ts +7 -2
  98. package/types/panel/schedules.d.ts +124 -4
  99. package/types/panel/schedulestart.d.ts +21 -3
  100. package/types/panel/server.d.ts +427 -6
  101. package/types/panel/settingsroutes.d.ts +4 -2
  102. package/types/panel/status.d.ts +16 -2
  103. package/types/panel/tickets.d.ts +61 -0
  104. package/types/pickrecord.d.ts +88 -0
  105. package/types/plan.d.ts +1 -0
  106. package/types/prcheckout.d.ts +151 -0
  107. package/types/readshim.d.ts +4 -3
  108. package/types/revises.d.ts +23 -0
  109. package/types/rubricstep.d.ts +14 -5
  110. package/types/run.d.ts +18 -1
  111. package/types/runlist.d.ts +6 -3
  112. package/types/schedulewords.d.ts +29 -2
  113. package/types/source.d.ts +40 -4
  114. package/types/stepmcp.d.ts +40 -0
  115. package/types/ticket.d.ts +114 -0
  116. package/types/ticketfilter.d.ts +34 -0
  117. package/types/ticketlabels.d.ts +44 -0
  118. package/types/ticketmcp.d.ts +84 -0
  119. package/types/ticketnext.d.ts +33 -0
  120. package/types/ticketrepo.d.ts +118 -0
  121. package/types/ticketschedule.d.ts +21 -0
  122. package/types/ticketshape.d.ts +37 -0
  123. package/types/tools.d.ts +1 -0
  124. package/types/trigger.d.ts +9 -1
  125. package/types/triggerclock.d.ts +6 -2
  126. package/types/triggerfiles.d.ts +13 -5
  127. package/types/triggertickets.d.ts +110 -0
  128. package/types/userrun.d.ts +50 -0
  129. package/types/validate.d.ts +1 -0
  130. package/types/worktree.d.ts +19 -0
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Why a ticket changed, in words, only for the watched fields; '' = nothing changed. @param {{state: string, labels: string[]}} prev @param {{state: string, labels: string[]}} cur @param {string[]} watch
3
+ */
4
+ export function reasonFor(prev: {
5
+ state: string;
6
+ labels: string[];
7
+ }, cur: {
8
+ state: string;
9
+ labels: string[];
10
+ }, watch: string[]): string;
11
+ /**
12
+ * One look. `seen` null = the first look after signing (the first page is the starting point, nothing runs). Otherwise newest first with the cursor, stopping at a seen
13
+ * number; with watched fields the walk goes on past it only as far as the oldest tracked ticket, comparing each tracked ticket's watched values with `last`.
14
+ * Every failure is `{ok:false, error}` naming its cause, at $0; none reads as "0 new".
15
+ * `cut` (first look only) = the highest ticket number the job's first green run read: the first look goes on past a page whose tickets are all above it, so every ticket
16
+ * that came in after that run started is seen; `recordLook` then baselines the ones up to `cut` and lets the rest arrive (fwd F114f).
17
+ * @param {{listUrl: string, mcp: {server: string, tool?: string}, configPath?: string, seen: Set<number>|null, last: Map<number, {state: string, labels: string[]}>, watch: string[], cut?: number, perPage?: number, timeoutMs?: number}} o
18
+ * @returns {Promise<{ok: true, first: boolean, cut?: number, ignored?: number[], found: Array<{number: number, state: string, labels: string[], createdAt: string|null}>, changed: Array<{number: number, reason: string, state: string, labels: string[]}>, pages: number} | {ok: false, error: string}>}
19
+ */
20
+ export function lookTickets({ listUrl, mcp, configPath: explicitConfig, seen, last, watch, cut, perPage, timeoutMs, }: {
21
+ listUrl: string;
22
+ mcp: {
23
+ server: string;
24
+ tool?: string;
25
+ };
26
+ configPath?: string;
27
+ seen: Set<number> | null;
28
+ last: Map<number, {
29
+ state: string;
30
+ labels: string[];
31
+ }>;
32
+ watch: string[];
33
+ cut?: number;
34
+ perPage?: number;
35
+ timeoutMs?: number;
36
+ }): Promise<{
37
+ ok: true;
38
+ first: boolean;
39
+ cut?: number;
40
+ ignored?: number[];
41
+ found: Array<{
42
+ number: number;
43
+ state: string;
44
+ labels: string[];
45
+ createdAt: string | null;
46
+ }>;
47
+ changed: Array<{
48
+ number: number;
49
+ reason: string;
50
+ state: string;
51
+ labels: string[];
52
+ }>;
53
+ pages: number;
54
+ } | {
55
+ ok: false;
56
+ error: string;
57
+ }>;
58
+ /** The numbers a signing has a baseline or an arrived row for. @param {string} ledger @param {string} sig */
59
+ export function seenNumbers(ledger: string, sig: string): Set<any>;
60
+ /** Last-seen watched values per number: the newest baseline/arrived row's. @param {string} ledger @param {string} sig @returns {Map<number, {state: string, labels: string[]}>} */
61
+ export function lastSeen(ledger: string, sig: string): Map<number, {
62
+ state: string;
63
+ labels: string[];
64
+ }>;
65
+ /**
66
+ * The cause of the newest look when it could not read, else null. The newest look row decides: an `unreadable` row is the problem until a later look reads
67
+ * (its `looked`, `baseline` or `arrived` row). @param {import('./triggerfiles.js').SeenRow[]} rows @returns {{at: number, why: string}|null}
68
+ */
69
+ export function lookProblemOf(rows: import("./triggerfiles.js").SeenRow[]): {
70
+ at: number;
71
+ why: string;
72
+ } | null;
73
+ /**
74
+ * Write what a look found, once. First look: a `baseline` row per ticket on the page (never runs). Later: an `arrived` row per new ticket, oldest first (its arrival
75
+ * time is this clock), and one `arrived` row per watched change with its `reason`. A look that could not read writes one `unreadable` row with its cause and NO `baseline`.
76
+ * @param {string} ledger @param {string} sig @param {Awaited<ReturnType<typeof lookTickets>>} look @param {number} at the scheduler's clock
77
+ * @returns {{arrived: number[], unreadable: string|null}}
78
+ */
79
+ export function recordLook(ledger: string, sig: string, look: Awaited<ReturnType<typeof lookTickets>>, at: number): {
80
+ arrived: number[];
81
+ unreadable: string | null;
82
+ };
83
+ /**
84
+ * "Run it anyway" (ITEM33-BUILD piece 4, borrowed-from fwdloop trigger-tickets.js@v0.29.0 `recordAnyway`): queue a ticket as a NEW arrival with the person's reason and `anyway: true`
85
+ * (the starter then says `--anyway`, so the job's filter never skips it). ONE `arrived` row; a ticket that is already in the queue is refused, never a second run.
86
+ * @param {string} ledger @param {string} sig @param {{number: number, reason: string}} a @param {number} at
87
+ * @returns {{ok: true} | {ok: false, say: string}}
88
+ */
89
+ export function recordAnyway(ledger: string, sig: string, a: {
90
+ number: number;
91
+ reason: string;
92
+ }, at: number): {
93
+ ok: true;
94
+ } | {
95
+ ok: false;
96
+ say: string;
97
+ };
98
+ /** A look every 15 minutes, fixed (item 8). */
99
+ export const TICKET_LOOK_MS: number;
100
+ /** The tool the look reads with: the signed `mcp.tools` must contain it (a schedule on a ticket job is refused at sign time otherwise). */
101
+ export const LOOK_TOOL: "list_issues";
102
+ export function watchedOf(i: any): {
103
+ state: string;
104
+ labels: any;
105
+ };
106
+ export function hasBaseline(ledger: string, sig: string): boolean;
107
+ export function recordTicketRan(ledger: string, sig: string, item: {
108
+ sha: string;
109
+ name: string;
110
+ }, at: number): boolean;
@@ -43,6 +43,14 @@ export function answerDoor(runId: string, decision: {
43
43
  export function main(argv: string[], deps?: Deps): Promise<number>;
44
44
  export type Deps = {
45
45
  env?: Record<string, string | undefined> | undefined;
46
+ /**
47
+ * piece 12: the PR a FRESH run of a code-repo job is checked out at (see `RunCtx.pr`); the door the PR reader will use, and the test seam. No flag sets it.
48
+ */
49
+ pr?: {
50
+ url: string;
51
+ record: any;
52
+ reread?: () => Promise<any>;
53
+ } | undefined;
46
54
  /**
47
55
  * P4a — a test seam naming the home whose `.env` keys file is loaded
48
56
  * even when `env` is injected; production never sets it.
@@ -73,6 +81,14 @@ export type Deps = {
73
81
  error: string;
74
82
  }>) | undefined;
75
83
  judgeProvider?: any;
84
+ /**
85
+ * R6 - a test seam: how a Tickets run that names no `--ticket` finds the newest unrun ticket (production: the real look, src/ticketnext.js)
86
+ */
87
+ newestUnrunTicket?: typeof newestUnrunTicket | undefined;
88
+ /**
89
+ * R6 - a test seam: the MCP config file that look reads (production: the person's own, found by src/mcpsources.js)
90
+ */
91
+ mcpConfig?: string | undefined;
76
92
  /**
77
93
  * F196 — a test seam for `appendRun`'s
78
94
  * (src/runlist.js) `home` override, the same shape `deps.provider` already
@@ -223,6 +239,39 @@ export type RunCtx = {
223
239
  * a FRESH `--spec` run: fetch the web inputs again AFTER the run is listed (never on resume/door/decide)
224
240
  */
225
241
  refreeze?: boolean | undefined;
242
+ /**
243
+ * a FRESH run of a job that reads tickets (flow type Tickets): the ticket number `--ticket` named (per run, never signed) and the job's signed `mcp`; `repo` = a code-repository (worktree) job, whose ticket is frozen into the worktree's private `.bareloop-input/` (src/ticketrepo.js) instead of the prepared copy's `input/`
244
+ */
245
+ ticket?: {
246
+ number: number;
247
+ mcp: {
248
+ server: string;
249
+ tools: string[];
250
+ };
251
+ repo?: true;
252
+ } | undefined;
253
+ /**
254
+ * R7b (5): a FRESH Tickets run that names no ticket: `execute` looks up the newest unrun one before it builds the run's row (so the row carries the number), and a refused look still lists the row and settles it at $0
255
+ */
256
+ pickNewest?: {
257
+ mcp: {
258
+ server: string;
259
+ tools: string[];
260
+ };
261
+ repo?: boolean;
262
+ } | undefined;
263
+ /**
264
+ * piece 12: a FRESH run of a code-repo job on a pull request: `url` = the PR address, `record` = the frozen PR record (its `head.sha` is what the worktree is checked out at, src/prcheckout.js), `reread` = read that record again once if the PR moved. Set by the PR reader (a repo job whose ticket line is a pulls list supplies it from its own frozen `pull_request_read`; this field is the override seam), never by a flag
265
+ */
266
+ pr?: {
267
+ url: string;
268
+ record: any;
269
+ reread?: () => Promise<any>;
270
+ } | undefined;
271
+ /**
272
+ * `--anyway`: run this ticket even if the job's filter would skip it (inert until the filter exists; it needs --ticket)
273
+ */
274
+ anyway?: boolean | undefined;
226
275
  model: string | null;
227
276
  providerKey: string | null;
228
277
  readShim: string | null;
@@ -240,3 +289,4 @@ export type RunCtx = {
240
289
  bundle?: BundleRun | undefined;
241
290
  deps: Deps;
242
291
  };
292
+ import { newestUnrunTicket } from './ticketnext.js';
@@ -224,6 +224,7 @@ export function sweepNestedQuantifiers(root: any, red: (code: string, path: stri
224
224
  * `.git` per repo, always at the workdir root, so its own runtime belt is a
225
225
  * single `fs.deny` entry). Both are inexpressible at declaration time, the
226
226
  * same law #1 already applies to `..`.
227
+ * The frozen-ticket folder (`.bareloop-input`, one spelling in worktree.js) is bareloop's own write, never the worker's: a fence naming it is refused the same way.
227
228
  * @type {readonly string[]}
228
229
  */
229
230
  export const FORBIDDEN_SCOPE_SEGMENTS: readonly string[];
@@ -23,6 +23,13 @@ export function shortHead(repo: string): string | null;
23
23
  * @returns {boolean} true when the line was added now
24
24
  */
25
25
  export function hideBareloopDir(repo: string): boolean;
26
+ /**
27
+ * Hide the frozen-ticket folder (`.bareloop-input/`) from `git status` and from `git add -A` in `dir` (a worktree) through the PRIVATE exclude:
28
+ * the COMMON git dir's `info/exclude`, which every linked worktree of that repo reads (a linked worktree has no `info/exclude` of its own). Never the tracked
29
+ * `.gitignore`. Idempotent.
30
+ * @param {string} dir a worktree (or repo) root @returns {boolean} true when the line was added now
31
+ */
32
+ export function hideTicketInput(dir: string): boolean;
26
33
  /**
27
34
  * Remove a run's worktree folder from `repo` (`git worktree remove --force`: the folder may hold untracked
28
35
  * scratch — a `.litectx/` index, the gate-audit file — and what matters is on the branch by now). Never throws.
@@ -30,6 +37,14 @@ export function hideBareloopDir(repo: string): boolean;
30
37
  * @returns {boolean} true when the folder is gone afterwards
31
38
  */
32
39
  export function removeWorktree(repo: string, dir: string): boolean;
40
+ /** the private ref a PR job's fetched head lives under (piece 12): bareloop's own namespace, so no branch, tag or the person's refs are touched and the object survives gc during the run @param {number} n */
41
+ export function prRefName(n: number): string;
42
+ /**
43
+ * Delete a PR job's private ref from `repo` (`git update-ref -d`). A leftover ref is harmless (one pointer into the object store) but is not left behind. Never throws.
44
+ * @param {string} repo @param {number} n
45
+ * @returns {boolean} true when the ref is gone afterwards (a ref that never existed counts)
46
+ */
47
+ export function removePrRef(repo: string, n: number): boolean;
33
48
  /**
34
49
  * The run's final commit, on whatever branch the worktree stands on: everything the run changed except the
35
50
  * arbiter's books and `node_modules`. Nothing changed = no commit (a green with nothing to commit is still a green).
@@ -46,3 +61,7 @@ export function commitWork(dir: string, message: string): {
46
61
  export const EXCLUDE_LINE: "/.bareloop/";
47
62
  /** the line that hides installed packages at any depth */
48
63
  export const NODE_MODULES_LINE: "node_modules/";
64
+ /** the folder inside a repo job's worktree that holds a frozen ticket (MCP + tickets piece 1a): one spelling */
65
+ export const TICKET_INPUT_DIR: ".bareloop-input";
66
+ /** the line that hides it (anchored at the top of each worktree) */
67
+ export const TICKET_INPUT_EXCLUDE_LINE: "/.bareloop-input/";