@volter/supercode-orchestrator 0.4.151 → 0.4.152

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.
package/board/ci.mjs CHANGED
@@ -40,7 +40,7 @@ const repositoryOf = (url) => new URL(url).pathname.split('/').slice(1, 3).join(
40
40
  const numberOf = (url) => Number(new URL(url).pathname.split('/')[4]);
41
41
  /** A PR as the board reads it (gh's field names). */
42
42
  const pullRequest = (repository, p) => ({ url: p.html_url, number: p.number, state: p.merged_at ? 'MERGED' : String(p.state).toUpperCase(), headRefOid: p.head.sha,
43
- headRefName: p.head.ref, baseRefName: p.base.ref, isCrossRepository: p.head.repo?.full_name?.toLowerCase() !== repository.toLowerCase(), isDraft: Boolean(p.draft) });
43
+ headRefName: p.head.ref, baseRefName: p.base.ref, defaultBranch: p.base.repo?.default_branch ?? null, isCrossRepository: p.head.repo?.full_name?.toLowerCase() !== repository.toLowerCase(), isDraft: Boolean(p.draft) });
44
44
  const readPullRequest = (url) => pullRequest(repositoryOf(url), github(`/repos/${repositoryOf(url)}/pulls/${numberOf(url)}`));
45
45
 
46
46
  const observations = new Map();
@@ -122,18 +122,22 @@ function registeredBranches(board, id) {
122
122
  return out;
123
123
  }
124
124
 
125
- /** Every opened PR of the arc: each open PR whose head is the card's branch or a `wt/<card id>` branch, in the
126
- * card's own repository and in every repository this machine keeps a checkout of, and each open PR on a sibling
127
- * checkout the arc registered (`registeredBranches`). One review covers them all; the caller decides the transition. */
125
+ /** Every opened PR of the arc, each proposed to its repository's default branch: an open PR whose head is the card's
126
+ * work branch in the card's own repository, a `wt/<card id>` branch in any repository this machine keeps a checkout
127
+ * of, or a sibling checkout the arc registered (`registeredBranches`). The repository's default branch, declared or
128
+ * checked out (or no branch), is not a work branch: such a card's PRs are only its `wt/<card>` and registered ones, and with none it
129
+ * answers `{ waits }` saying so. One review covers them all; the caller decides the transition. */
128
130
  export function openReviewPullRequests(board, id) {
129
131
  const own = repositoryWorkspace(board, id);
130
132
  if (!own) return null;
131
133
  const task = board.db.prepare('SELECT branch_name FROM tasks WHERE id=?').get(id);
132
- const branch = task?.branch_name ?? run('git', ['branch', '--show-current'], own);
133
134
  const ownRepository = originOf(own);
134
135
  if (!ownRepository) return null;
136
+ const current = task?.branch_name ? null : run('git', ['branch', '--show-current'], own);
137
+ let branch = task?.branch_name ?? (current || null);
135
138
  const registered = registeredBranches(board, id);
136
- const mine = (repository, head) => head === branch || [`wt/${id}`, `wt/${id.replace(/^t_/, 't-')}`].some((prefix) => head === prefix || head.startsWith(`${prefix}-`) || head.startsWith(`${prefix}/`))
139
+ const named = (head) => [`wt/${id}`, `wt/${id.replace(/^t_/, 't-')}`].some((prefix) => head === prefix || head.startsWith(`${prefix}-`) || head.startsWith(`${prefix}/`));
140
+ const mine = (repository, head) => (repository === ownRepository && head === branch) || named(head)
137
141
  || registered.some((r) => r.repository === repository && r.branch === head);
138
142
  const prs = [];
139
143
  for (const repository of new Set([ownRepository, ...registered.map((r) => r.repository), ...knownRepositories()])) {
@@ -147,10 +151,15 @@ export function openReviewPullRequests(board, id) {
147
151
  if (pullRequestLists.size >= 64) pullRequestLists.delete(pullRequestLists.keys().next().value);
148
152
  pullRequestLists.set(repository, list);
149
153
  }
150
- // a draft is not handed over yet: its review starts when it is marked ready
151
- for (const pr of list.items) if (!pr.isCrossRepository && !pr.isDraft && mine(repository, pr.headRefName)) prs.push({ url: pr.url, head: pr.headRefOid });
154
+ // The repository's default branch is not a work branch, declared or checked out (a card working in a `dir` on main).
155
+ if (repository === ownRepository && branch) {
156
+ const defaultBranch = list.items.find((pr) => pr.defaultBranch)?.defaultBranch ?? (() => { try { return run('git', ['symbolic-ref', '--quiet', '--short', 'refs/remotes/origin/HEAD'], own).replace(/^origin\//, ''); } catch { return null; } })();
157
+ if (branch === defaultBranch) branch = null;
158
+ }
159
+ // a draft is not handed over yet: its review starts when it is marked ready; a PR to another base (main→prod) is a release, not the arc's work
160
+ for (const pr of list.items) if (!pr.isCrossRepository && !pr.isDraft && pr.baseRefName === pr.defaultBranch && mine(repository, pr.headRefName)) prs.push({ url: pr.url, head: pr.headRefOid });
152
161
  }
153
- if (!prs.length) return null;
162
+ if (!prs.length) return branch ? null : { waits: `the card has no work branch (${task?.branch_name ? `it declares ${task.branch_name}, its repository's default` : current ? `its checkout ${own} is on ${current}, its repository's default` : `its checkout ${own} is on no branch`}): give it one with --branch, or open its PR from a wt/${id} branch` };
154
163
  return { pr: prs.map((p) => p.url), pr_head: prs.map((p) => p.head), branch };
155
164
  }
156
165
 
@@ -1880,6 +1880,7 @@ async function activatePullRequestReviews(board, entry, report, effects, { only
1880
1880
  // The arc's open PRs ask for one review only while some head has no verdict: after changes are
1881
1881
  // requested the next run is the implementer's, until a new head is pushed.
1882
1882
  if (!payload) { report.queued.push([id, 'review waits: no open PR on its branch, a wt/<card> branch or a registered checkout']); continue; }
1883
+ if (payload.waits) { report.queued.push([id, `review waits: ${payload.waits}`]); payload = null; continue; }
1883
1884
  if (!reviewDue(board, id, payload.pr.map((url, index) => ({ url, head: payload.pr_head[index] })))) {
1884
1885
  report.queued.push([id, `review waits: every open PR head (${payload.pr.join(', ')}) has a verdict or predates the last one; push a commit that answers it`]);
1885
1886
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-orchestrator",
3
- "version": "0.4.151",
3
+ "version": "0.4.152",
4
4
  "type": "module",
5
5
  "description": "The orchestrator runtime over the Volter Harness ontology: one typed operational model whose folder is its serialization, read and written through the harness orchestration doors (docs/ORCHESTRATOR-IR.md)",
6
6
  "exports": {