lastlight-core 0.40.3 → 0.40.4

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.
@@ -914,7 +914,8 @@ routes:
914
914
  # flow). The router drops every label that is not a configured
915
915
  # `autonomy.stages.*.enter`, so this is inert until `autonomy.repos` names
916
916
  # a repo — and it is guard 1 of the four that replace the bot-sender filter
917
- # we deliberately opened for `issues.labeled`.
917
+ # we deliberately opened for `issues.labeled`. A stage's own `workflow`
918
+ # wins over this route; it is only the fallback for a stage that names none.
918
919
  issue_labeled: build
919
920
  pr_opened: pr-review
920
921
  pr_synchronize: pr-review
@@ -49,11 +49,14 @@ const MAX_BOARD_REPOS = 20;
49
49
  * is a much larger thing than the button says it is — and it already exists,
50
50
  * deliberately, as `POST /api/run` for operators who want it.
51
51
  *
52
- * So the workflow is resolved from `routes.github` — the operator's own route
53
- * map — and then CHECKED to be one of these three keys' values. An operator who
54
- * repoints `issue_build` at a different workflow moves this surface with it,
55
- * which is right; an operator who never configured the stage at all gets a
56
- * refusal rather than a dispatch, which is also right.
52
+ * So the workflow is resolved from operator config — the stage's own
53
+ * `workflow` (`stageWorkflow`) — and then CHECKED to be one the operator
54
+ * already points an issue trigger at: one of these three keys' values, or a
55
+ * configured stage's workflow. `autonomy.stages` is operator-only config, so a
56
+ * stage's workflow is as much the operator's decision as a route is; leaving it
57
+ * out refused every stage that names its own workflow (issue #452). An operator
58
+ * who never configured the workflow at all still gets a refusal rather than a
59
+ * dispatch.
57
60
  */
58
61
  const ISSUE_DISPATCH_ROUTE_KEYS = ["issue_opened", "issue_labeled", "issue_build"];
59
62
  const STAGE_SLOTS = ["enter", "running", "on_success", "on_failure"];
@@ -99,7 +102,10 @@ function stageSlotForLabel(label) {
99
102
  * drifts open is a "run anything against any managed repo" hole.
100
103
  */
101
104
  function isIssueRoutableWorkflow(workflow) {
102
- const routable = new Set(ISSUE_DISPATCH_ROUTE_KEYS.map((key) => getRoutes().github?.[key]).filter(Boolean));
105
+ const routable = new Set([
106
+ ...ISSUE_DISPATCH_ROUTE_KEYS.map((key) => getRoutes().github?.[key]).filter(Boolean),
107
+ ...Object.values(getAutonomyConfig().stages).map(stageWorkflow),
108
+ ]);
103
109
  return routable.has(workflow);
104
110
  }
105
111
  import { getRuntimeConfig, getRoutes, getBotName, resolveKubernetesConfig,
@@ -108,7 +114,7 @@ import { getRuntimeConfig, getRoutes, getBotName, resolveKubernetesConfig,
108
114
  // returns a repo's UNTRUSTED `.lastlight/lastlight.yml` raw and
109
115
  // pre-validation, so a copy that drifted behind config.ts's would leak a
110
116
  // pasted credential. It must stay single-source (see config.ts).
111
- redactPublic, getAutonomyConfig, getHoldLabel, } from "../config/config.js";
117
+ redactPublic, getAutonomyConfig, stageWorkflow, getHoldLabel, } from "../config/config.js";
112
118
  import { fetchRepoLayer, refreshRepoLayer, getCachedRepoLayer, repoConfigPolicy, repoConfigBaseFromRuntime, resolveRepoConfig, } from "../config/repo-config.js";
113
119
  import { issueTriggerId } from "../engine/build-decisions.js";
114
120
  import { applyBuildDispatchGate } from "../engine/build-gate.js";
@@ -2943,11 +2949,12 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2943
2949
  if (!stageName || !stage) {
2944
2950
  return c.json({ error: `unknown stage: \`${stageName ?? ""}\` is not in \`autonomy.stages\`` }, 400);
2945
2951
  }
2952
+ const workflow = stageWorkflow(stage);
2946
2953
  // THE ALLOW-LIST. See `ISSUE_DISPATCH_ROUTE_KEYS` — the workflow has to be
2947
2954
  // one the operator's own route map already points an issue trigger at.
2948
- if (!isIssueRoutableWorkflow(stage.workflow)) {
2955
+ if (!isIssueRoutableWorkflow(workflow)) {
2949
2956
  return c.json({
2950
- error: `workflow \`${stage.workflow}\` is not reachable from an issue route ` +
2957
+ error: `workflow \`${workflow}\` is not reachable from an issue route ` +
2951
2958
  `(${ISSUE_DISPATCH_ROUTE_KEYS.join(", ")}), so the board may not dispatch it`,
2952
2959
  }, 400);
2953
2960
  }
@@ -3006,7 +3013,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
3006
3013
  outcome: "denied",
3007
3014
  detail: {
3008
3015
  stage: stageName,
3009
- workflow: stage.workflow,
3016
+ workflow,
3010
3017
  dispatched: false,
3011
3018
  reason: String(gate.reason ?? "").slice(0, 200),
3012
3019
  ...(reason ? { note: reason } : {}),
@@ -3016,7 +3023,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
3016
3023
  repo,
3017
3024
  issueNumber,
3018
3025
  stage: stageName,
3019
- workflow: stage.workflow,
3026
+ workflow,
3020
3027
  dispatched: false,
3021
3028
  // The hold is the one skip that owes a human a sentence rather than a
3022
3029
  // reason string, and it is the SAME sentence every other surface
@@ -3027,8 +3034,8 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
3027
3034
  }
3028
3035
  // Fire-and-forget, exactly like `cron trigger` and the PR retry above: a
3029
3036
  // build takes minutes and the dashboard is waiting on this response.
3030
- log.info("board dispatch", { workflow: stage.workflow, repo, issueNumber, stage: stageName, by });
3031
- config.dispatchWorkflow(stage.workflow, {
3037
+ log.info("board dispatch", { workflow, repo, issueNumber, stage: stageName, by });
3038
+ config.dispatchWorkflow(workflow, {
3032
3039
  repo,
3033
3040
  issueNumber,
3034
3041
  title: live.title,
@@ -3045,7 +3052,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
3045
3052
  sender: by,
3046
3053
  triggeredBy: by,
3047
3054
  }).catch((err) => {
3048
- log.error("board dispatch failed", { workflow: stage.workflow, repo, issueNumber, err });
3055
+ log.error("board dispatch failed", { workflow, repo, issueNumber, err });
3049
3056
  });
3050
3057
  // The freshness lever that matters. Without this the card keeps rendering
3051
3058
  // its pre-dispatch stage for up to the full TTL, so the button appears to
@@ -3057,7 +3064,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
3057
3064
  targetId,
3058
3065
  detail: {
3059
3066
  stage: stageName,
3060
- workflow: stage.workflow,
3067
+ workflow,
3061
3068
  dispatched: true,
3062
3069
  ...(reason ? { note: reason } : {}),
3063
3070
  },
@@ -3066,7 +3073,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
3066
3073
  repo,
3067
3074
  issueNumber,
3068
3075
  stage: stageName,
3069
- workflow: stage.workflow,
3076
+ workflow,
3070
3077
  dispatched: true,
3071
3078
  reason: gate.reason,
3072
3079
  });
@@ -3326,8 +3333,8 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
3326
3333
  // bills.
3327
3334
  if (labels.includes(to))
3328
3335
  return `already-in-stage: ${repo}#${issueNumber} already carries \`${to}\``;
3329
- if (!isIssueRoutableWorkflow(matchedStage.workflow)) {
3330
- return (`unroutable-workflow: \`${matchedStage.workflow}\` is not reachable from an ` +
3336
+ if (!isIssueRoutableWorkflow(stageWorkflow(matchedStage))) {
3337
+ return (`unroutable-workflow: \`${stageWorkflow(matchedStage)}\` is not reachable from an ` +
3331
3338
  `issue route (${ISSUE_DISPATCH_ROUTE_KEYS.join(", ")})`);
3332
3339
  }
3333
3340
  return undefined;
@@ -3401,7 +3408,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
3401
3408
  });
3402
3409
  }
3403
3410
  }
3404
- fireDispatch(slotMatch.stage, matchedStage.workflow, gate.gates);
3411
+ fireDispatch(slotMatch.stage, stageWorkflow(matchedStage), gate.gates);
3405
3412
  invalidateBoard(repo);
3406
3413
  await recordActivityFor(c, db, {
3407
3414
  action: "issue.stage",
@@ -3462,7 +3469,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
3462
3469
  if (!gateFirst && dispatchRefusal === undefined && slotMatch?.kind === "match" && matchedStage) {
3463
3470
  const gate = await crossGate(slotMatch.stage);
3464
3471
  if (gate.decision === "dispatch") {
3465
- fireDispatch(slotMatch.stage, matchedStage.workflow, gate.gates);
3472
+ fireDispatch(slotMatch.stage, stageWorkflow(matchedStage), gate.gates);
3466
3473
  }
3467
3474
  }
3468
3475
  // A failed REMOVE is not an error. The issue now carries BOTH labels, which