lastlight-core 0.28.0 → 0.28.2

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 (83) hide show
  1. package/dist/activity.d.ts +19 -0
  2. package/dist/activity.js +28 -0
  3. package/dist/activity.js.map +1 -0
  4. package/dist/admin/activity.d.ts +16 -0
  5. package/dist/admin/activity.js +21 -0
  6. package/dist/admin/activity.js.map +1 -0
  7. package/dist/admin/auth.d.ts +10 -0
  8. package/dist/admin/auth.js +22 -1
  9. package/dist/admin/auth.js.map +1 -1
  10. package/dist/admin/routes.js +211 -7
  11. package/dist/admin/routes.js.map +1 -1
  12. package/dist/cron/dependabot-discovery.d.ts +1 -1
  13. package/dist/cron/handlers.js +20 -0
  14. package/dist/cron/handlers.js.map +1 -1
  15. package/dist/cron/runner.js +24 -2
  16. package/dist/cron/runner.js.map +1 -1
  17. package/dist/engine/dispatcher.js +77 -2
  18. package/dist/engine/dispatcher.js.map +1 -1
  19. package/dist/engine/fix-harvest.js +2 -2
  20. package/dist/engine/fix-harvest.js.map +1 -1
  21. package/dist/engine/github/review-poster.d.ts +21 -0
  22. package/dist/engine/github/review-poster.js +71 -3
  23. package/dist/engine/github/review-poster.js.map +1 -1
  24. package/dist/engine/pr-decisions.js +3 -3
  25. package/dist/engine/pr-decisions.js.map +1 -1
  26. package/dist/engine/pr-state.d.ts +1 -1
  27. package/dist/engine/pr-state.js +3 -3
  28. package/dist/engine/pr-state.js.map +1 -1
  29. package/dist/index.js +47 -6
  30. package/dist/index.js.map +1 -1
  31. package/dist/sandbox/reap.d.ts +1 -1
  32. package/dist/sandbox/reap.js +1 -1
  33. package/dist/state/activity-store.d.ts +118 -0
  34. package/dist/state/activity-store.js +173 -0
  35. package/dist/state/activity-store.js.map +1 -0
  36. package/dist/state/data-migrate.js +3 -0
  37. package/dist/state/data-migrate.js.map +1 -1
  38. package/dist/state/db.d.ts +9 -0
  39. package/dist/state/db.js +9 -0
  40. package/dist/state/db.js.map +1 -1
  41. package/dist/state/schema/pg.d.ts +171 -0
  42. package/dist/state/schema/pg.js +16 -0
  43. package/dist/state/schema/pg.js.map +1 -1
  44. package/dist/state/schema/sqlite.d.ts +197 -0
  45. package/dist/state/schema/sqlite.js +30 -0
  46. package/dist/state/schema/sqlite.js.map +1 -1
  47. package/dist/workflows/handlers/post-review.js +13 -1
  48. package/dist/workflows/handlers/post-review.js.map +1 -1
  49. package/dist/workflows/runner.d.ts +11 -0
  50. package/dist/workflows/runner.js +17 -33
  51. package/dist/workflows/runner.js.map +1 -1
  52. package/dist/workflows/simple.d.ts +3 -4
  53. package/dist/workflows/simple.js +32 -25
  54. package/dist/workflows/simple.js.map +1 -1
  55. package/dist/workflows/target-policy.d.ts +95 -73
  56. package/dist/workflows/target-policy.js +147 -96
  57. package/dist/workflows/target-policy.js.map +1 -1
  58. package/drizzle/pg/0001_brief_gargoyle.sql +15 -0
  59. package/drizzle/pg/meta/0001_snapshot.json +1876 -0
  60. package/drizzle/pg/meta/_journal.json +7 -0
  61. package/drizzle/sqlite/0002_aromatic_vector.sql +15 -0
  62. package/drizzle/sqlite/meta/0002_snapshot.json +1704 -0
  63. package/drizzle/sqlite/meta/_journal.json +8 -1
  64. package/package.json +6 -6
  65. package/skills/adjudicate-pass/SKILL.md +28 -0
  66. package/workflows/answer.yaml +4 -0
  67. package/workflows/build.yaml +8 -0
  68. package/workflows/demo.yaml +10 -0
  69. package/workflows/dependabot-ci-fix.yaml +7 -0
  70. package/workflows/dependabot-pr-merge.yaml +7 -0
  71. package/workflows/explore.yaml +4 -0
  72. package/workflows/issue-comment.yaml +4 -0
  73. package/workflows/issue-triage.yaml +4 -0
  74. package/workflows/pr-comment.yaml +4 -0
  75. package/workflows/pr-fix.yaml +7 -0
  76. package/workflows/pr-review.yaml +9 -0
  77. package/workflows/prompts/review-adjudicate.md +9 -0
  78. package/workflows/prompts/review.md +6 -0
  79. package/workflows/qa-test.yaml +10 -0
  80. package/workflows/repo-health.yaml +5 -0
  81. package/workflows/security-feedback.yaml +4 -0
  82. package/workflows/security-review.yaml +4 -0
  83. package/workflows/verify.yaml +10 -0
@@ -0,0 +1,19 @@
1
+ import type { ActivityEntry, StateDb } from "./state/db.js";
2
+ /**
3
+ * Append one activity row, BEST-EFFORT (issue #206).
4
+ *
5
+ * This is the entire best-effort contract, and it lives here rather than in
6
+ * `ActivityStore.record` on purpose: the store throws like any other store
7
+ * method, so a test can still observe a write failing. Swallowing inside the
8
+ * store would make "a logging failure never fails the action" unfalsifiable.
9
+ *
10
+ * The rule it enforces: **recording that something happened must never stop it
11
+ * from happening.** Same posture as #205's identity capture and every read in
12
+ * `pr-state.ts` — an audit trail is worth less than the action it describes.
13
+ *
14
+ * Lives at `src/` rather than under `admin/` because every layer writes to it:
15
+ * the admin routes, `dispatchWorkflow` in `index.ts`, the dispatcher's approval
16
+ * seam and the cron runner. `admin/activity.ts` adds the Hono-flavoured wrapper
17
+ * on top for the request-scoped case.
18
+ */
19
+ export declare function recordActivity(db: StateDb, entry: ActivityEntry): Promise<void>;
@@ -0,0 +1,28 @@
1
+ import { logger } from "./logging/logger.js";
2
+ const log = logger("activity");
3
+ /**
4
+ * Append one activity row, BEST-EFFORT (issue #206).
5
+ *
6
+ * This is the entire best-effort contract, and it lives here rather than in
7
+ * `ActivityStore.record` on purpose: the store throws like any other store
8
+ * method, so a test can still observe a write failing. Swallowing inside the
9
+ * store would make "a logging failure never fails the action" unfalsifiable.
10
+ *
11
+ * The rule it enforces: **recording that something happened must never stop it
12
+ * from happening.** Same posture as #205's identity capture and every read in
13
+ * `pr-state.ts` — an audit trail is worth less than the action it describes.
14
+ *
15
+ * Lives at `src/` rather than under `admin/` because every layer writes to it:
16
+ * the admin routes, `dispatchWorkflow` in `index.ts`, the dispatcher's approval
17
+ * seam and the cron runner. `admin/activity.ts` adds the Hono-flavoured wrapper
18
+ * on top for the request-scoped case.
19
+ */
20
+ export async function recordActivity(db, entry) {
21
+ try {
22
+ await db.activity.record(entry);
23
+ }
24
+ catch (err) {
25
+ log.warn("activity write failed", { err, action: entry.action, target: entry.targetId });
26
+ }
27
+ }
28
+ //# sourceMappingURL=activity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity.js","sourceRoot":"","sources":["../src/activity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AAE/B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EAAW,EAAE,KAAoB;IACpE,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,GAAG,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3F,CAAC;AACH,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { Context } from "hono";
2
+ import type { ActivityEntry, StateDb, TriggerActorType } from "../state/db.js";
3
+ /**
4
+ * {@link recordActivity} with the actor filled in from the request — the
5
+ * request-scoped half of the activity seam (issue #206).
6
+ *
7
+ * `actorLogin` is left NULL when the session carries no verified login: a
8
+ * password login and an auth-disabled instance both produce that. Deliberately
9
+ * NOT defaulted to `"admin"` the way the `updated_by` columns are — in an audit
10
+ * stream `"admin"` reads as a person, and "we do not know who" is the truer
11
+ * statement. `actor_type` still records `admin`, so the row is not anonymous
12
+ * about HOW it happened, only about who.
13
+ */
14
+ export declare function recordActivityFor(c: Context, db: StateDb, entry: Omit<ActivityEntry, "actorLogin" | "actorType"> & {
15
+ actorType?: TriggerActorType;
16
+ }): Promise<void>;
@@ -0,0 +1,21 @@
1
+ import { recordActivity } from "../activity.js";
2
+ import { actorFromContext, actorTypeFromContext } from "./auth.js";
3
+ /**
4
+ * {@link recordActivity} with the actor filled in from the request — the
5
+ * request-scoped half of the activity seam (issue #206).
6
+ *
7
+ * `actorLogin` is left NULL when the session carries no verified login: a
8
+ * password login and an auth-disabled instance both produce that. Deliberately
9
+ * NOT defaulted to `"admin"` the way the `updated_by` columns are — in an audit
10
+ * stream `"admin"` reads as a person, and "we do not know who" is the truer
11
+ * statement. `actor_type` still records `admin`, so the row is not anonymous
12
+ * about HOW it happened, only about who.
13
+ */
14
+ export async function recordActivityFor(c, db, entry) {
15
+ await recordActivity(db, {
16
+ ...entry,
17
+ actorLogin: actorFromContext(c) ?? null,
18
+ actorType: entry.actorType ?? actorTypeFromContext(c) ?? null,
19
+ });
20
+ }
21
+ //# sourceMappingURL=activity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity.js","sourceRoot":"","sources":["../../src/admin/activity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEnE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,CAAU,EACV,EAAW,EACX,KAAyF;IAEzF,MAAM,cAAc,CAAC,EAAE,EAAE;QACvB,GAAG,KAAK;QACR,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC,IAAI,IAAI;QACvC,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,oBAAoB,CAAC,CAAC,CAAC,IAAI,IAAI;KAC9D,CAAC,CAAC;AACL,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import type { Context, Next } from "hono";
2
+ import type { TriggerActorType } from "../state/db.js";
2
3
  /**
3
4
  * Grace window past `exp` in which a token can still be *refreshed* (but not
4
5
  * used to authenticate a normal request). Lets an active user whose token
@@ -61,3 +62,12 @@ export declare function authMiddleware(enabled: boolean, secret: string): (c: Co
61
62
  * falling back to `cli`/`admin` when it returns undefined (issue #205).
62
63
  */
63
64
  export declare function actorFromContext(c: Context): string | undefined;
65
+ /**
66
+ * How the current actor authenticated, as a {@link TriggerActorType} — the
67
+ * activity log's `actor_type` (issue #206).
68
+ *
69
+ * A `password` session maps to `admin`, not to a person: it carries no verified
70
+ * login, which is exactly why {@link actorFromContext} returns undefined
71
+ * alongside it. Undefined here means auth is disabled entirely.
72
+ */
73
+ export declare function actorTypeFromContext(c: Context): TriggerActorType | undefined;
@@ -125,7 +125,10 @@ export function authMiddleware(enabled, secret) {
125
125
  }
126
126
  // Surface the verified identity to downstream routes (issue #205). The
127
127
  // single seam every actor-hardcoded route reads via {@link actorFromContext}.
128
- c.set("actorLogin", decodeToken(token)?.login);
128
+ const decoded = decodeToken(token);
129
+ c.set("actorLogin", decoded?.login);
130
+ // How they authenticated, for the activity log's `actor_type` (issue #206).
131
+ c.set("actorMethod", decoded?.method);
129
132
  return next();
130
133
  };
131
134
  }
@@ -140,4 +143,22 @@ export function authMiddleware(enabled, secret) {
140
143
  export function actorFromContext(c) {
141
144
  return c.get("actorLogin");
142
145
  }
146
+ /**
147
+ * How the current actor authenticated, as a {@link TriggerActorType} — the
148
+ * activity log's `actor_type` (issue #206).
149
+ *
150
+ * A `password` session maps to `admin`, not to a person: it carries no verified
151
+ * login, which is exactly why {@link actorFromContext} returns undefined
152
+ * alongside it. Undefined here means auth is disabled entirely.
153
+ */
154
+ export function actorTypeFromContext(c) {
155
+ const method = c.get("actorMethod");
156
+ if (method === "github")
157
+ return "github";
158
+ if (method === "slack")
159
+ return "slack";
160
+ if (method === "password")
161
+ return "admin";
162
+ return undefined;
163
+ }
143
164
  //# sourceMappingURL=auth.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/admin/auth.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAGjC,MAAM,iBAAiB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,E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AAI,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAAU;IACzC,OAAO,CAAC,CAAC,GAAG,CAAC,YAAY,CAAuB,CAAC;AACnD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,CAAU;IAC7C,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,aAAa,CAAuC,CAAC;IAC1E,IAAI,MAAM,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IACzC,IAAI,MAAM,KAAK,OAAO;QAAE,OAAO,OAAO,CAAC;IACvC,IAAI,MAAM,KAAK,UAAU;QAAE,OAAO,OAAO,CAAC;IAC1C,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -5,7 +5,7 @@ import { getCookie, setCookie, deleteCookie } from "hono/cookie";
5
5
  import { Slack, GitHub } from "arctic";
6
6
  import { tailJsonl } from "./tail.js";
7
7
  import { listRunningContainers, killContainer, getContainerStats, getHostStats, listServerContainers, resolveServerContainer, getContainerLogs, streamContainerLogs, } from "./docker.js";
8
- import { authMiddleware, createToken, verifyTokenForRefresh, decodeToken, actorFromContext } from "./auth.js";
8
+ import { authMiddleware, createToken, verifyTokenForRefresh, decodeToken, actorFromContext, actorTypeFromContext } from "./auth.js";
9
9
  import { Cron } from "croner";
10
10
  import { CRON_GLOBALLY_ENABLED_KEY, CRON_NAME_KEY, cronVote, repoCronPrefs, repoLayerMayVote, } from "../cron/repo-crons.js";
11
11
  import { enumerateOverlayAssets } from "lastlight-shared/overlay-assets";
@@ -14,7 +14,7 @@ import { routeEvent } from "../engine/router.js";
14
14
  import { applyPrDispatchGate, prPolicyConfig } from "../engine/dispatcher.js";
15
15
  import { resolvePrState, prTriggerId } from "../engine/pr-state.js";
16
16
  import { holdReply } from "../engine/pr-decisions.js";
17
- import { PR_FIX_SHAPED_WORKFLOWS } from "../workflows/target-policy.js";
17
+ import { prFixShapedWorkflows } from "../workflows/target-policy.js";
18
18
  import { classifyComment } from "../engine/screen/classifier.js";
19
19
  import { getWorkflowTriggers, getWorkflowTriggerKinds, resolveIntentHandler, } from "../workflows/triggers.js";
20
20
  import { getManagedRepos, getInstallationRepoBreakdown, getInstallationRepos, getInstallationReposRefreshedAt, isManagedRepo, } from "../managed-repos.js";
@@ -43,6 +43,8 @@ import { RunId } from "../sandbox/k8s/run-id.js";
43
43
  import { getServerVersion } from "./version.js";
44
44
  import { BuildAssetStore, buildAssetIssueKey } from "../state/build-assets.js";
45
45
  import { logger } from "../logging/logger.js";
46
+ import { recordActivity } from "../activity.js";
47
+ import { recordActivityFor } from "./activity.js";
46
48
  const log = logger("admin");
47
49
  const oauthLog = logger("oauth");
48
50
  /**
@@ -682,6 +684,16 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
682
684
  const a = Buffer.from(body.password);
683
685
  const b = Buffer.from(config.adminPassword);
684
686
  const ok = a.length === b.length && timingSafeEqual(a, b);
687
+ // A failed password attempt is one of the few things an audit stream is
688
+ // unambiguously for. `actorType` is passed explicitly because there is no
689
+ // token yet — the context this route runs in carries no actor at all, and
690
+ // password login never learns a login.
691
+ await recordActivity(db, {
692
+ action: "login",
693
+ actorType: "admin",
694
+ outcome: ok ? "ok" : "denied",
695
+ detail: { method: "password" },
696
+ });
685
697
  if (!ok) {
686
698
  return c.json({ error: "invalid password" }, 401);
687
699
  }
@@ -793,6 +805,15 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
793
805
  }
794
806
  }
795
807
  const token = createToken(config.adminSecret, "slack", matchedLogin);
808
+ // `actorLogin` is the MATCHED GitHub login, or null when the email did not
809
+ // resolve to a `users` row — the same degradation #205 documents for the
810
+ // Slack connector, and the reason this column is nullable.
811
+ await recordActivity(db, {
812
+ action: "login",
813
+ actorLogin: matchedLogin ?? null,
814
+ actorType: "slack",
815
+ detail: { method: "slack", matched: !!matchedLogin },
816
+ });
796
817
  // Redirect to dashboard with token in URL; App.tsx strips it immediately.
797
818
  // Trailing slash matters: Vite serves the SPA with base "/admin/" so a
798
819
  // bare "/admin" 404s in dev. Production static serving accepts both.
@@ -882,6 +903,15 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
882
903
  org: config.githubAllowedOrg,
883
904
  memberStatus,
884
905
  });
906
+ // A rejected login names a real, verified GitHub identity — the one
907
+ // denial in here where we know exactly who was turned away.
908
+ await recordActivity(db, {
909
+ action: "login",
910
+ actorLogin: login,
911
+ actorType: "github",
912
+ outcome: "denied",
913
+ detail: { method: "github", reason: "not_org_member", org: config.githubAllowedOrg },
914
+ });
885
915
  return fail("github_org");
886
916
  }
887
917
  // Capture a first-class user identity (issue #205). A public GitHub
@@ -927,6 +957,12 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
927
957
  // Carry the verified login in the token so actor-hardcoded routes
928
958
  // attribute to this person.
929
959
  const token = createToken(config.adminSecret, "github", login);
960
+ await recordActivity(db, {
961
+ action: "login",
962
+ actorLogin: login,
963
+ actorType: "github",
964
+ detail: { method: "github" },
965
+ });
930
966
  return c.redirect(`/admin/?token=${encodeURIComponent(token)}`);
931
967
  }
932
968
  catch (err) {
@@ -1090,9 +1126,24 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1090
1126
  await db.executions.recordFinish(e.id, { success: false, error: "terminated via admin dashboard" });
1091
1127
  }
1092
1128
  }
1129
+ await recordActivityFor(c, db, {
1130
+ action: "container.kill",
1131
+ targetType: "container",
1132
+ targetId: name,
1133
+ });
1093
1134
  return c.json({ killed: name });
1094
1135
  }
1095
1136
  catch (err) {
1137
+ // The kill itself failed — record the attempt, since "someone tried to
1138
+ // kill this and could not" is exactly the kind of thing an audit stream
1139
+ // is read for.
1140
+ await recordActivityFor(c, db, {
1141
+ action: "container.kill",
1142
+ targetType: "container",
1143
+ targetId: name,
1144
+ outcome: "error",
1145
+ detail: { error: String(err?.message ?? err).slice(0, 200) },
1146
+ });
1096
1147
  return c.json({ error: err.message }, 500);
1097
1148
  }
1098
1149
  });
@@ -1215,6 +1266,50 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1215
1266
  app.get("/workflow-names", async (c) => {
1216
1267
  return c.json({ names: await db.runs.distinctNames() });
1217
1268
  });
1269
+ // ── Activity log — the audit feed (issue #206) ────────────────────────────
1270
+ //
1271
+ // Deliberately NOT repo-scoped, unlike `/workflow-runs` and `/sessions`.
1272
+ // Their `?repos=` is UI declutter rather than authorization (see the note at
1273
+ // the top of `/me/repos`), and an audit stream silently filtered by which
1274
+ // teams you happen to belong to would be misleading in a way a run list is
1275
+ // not. Narrowing this one is a real authorization decision, not a copied
1276
+ // query param.
1277
+ app.get("/activity", async (c) => {
1278
+ const limit = Math.min(Math.max(parseInt(c.req.query("limit") ?? "50", 10) || 50, 1), 200);
1279
+ const offset = Math.max(parseInt(c.req.query("offset") ?? "0", 10) || 0, 0);
1280
+ // `<type>:<id>`, split on the FIRST colon — a target id can contain one
1281
+ // (`repo:acme/widgets#7` does not, but `container:lastlight-sandbox-a:b`
1282
+ // could), and the type never does.
1283
+ const rawTarget = c.req.query("target") || undefined;
1284
+ const sep = rawTarget?.indexOf(":") ?? -1;
1285
+ const targetType = rawTarget ? (sep >= 0 ? rawTarget.slice(0, sep) : rawTarget) : undefined;
1286
+ const targetId = rawTarget && sep >= 0 ? rawTarget.slice(sep + 1) : undefined;
1287
+ const { activity, total } = await db.activity.list({
1288
+ limit,
1289
+ offset,
1290
+ actor: c.req.query("actor") || undefined,
1291
+ action: c.req.query("action") || undefined,
1292
+ targetType,
1293
+ targetId,
1294
+ sinceIso: c.req.query("since") || undefined,
1295
+ });
1296
+ // Enrich from `users` for name + avatar, the way `GET /workflow-runs/:id`
1297
+ // does for `triggered_by` (issue #205). Resolved ONCE per distinct login
1298
+ // rather than per row: a page of 50 is routinely two or three people.
1299
+ const logins = [...new Set(activity.map((a) => a.actorLogin).filter(Boolean))];
1300
+ const users = {};
1301
+ for (const login of logins) {
1302
+ const user = await db.users.findByLogin(login);
1303
+ if (user)
1304
+ users[login] = { login: user.login, name: user.name, avatarUrl: user.avatarUrl };
1305
+ }
1306
+ return c.json({ activity, total, users });
1307
+ });
1308
+ // The distinct verbs actually present, for the dashboard's filter dropdown —
1309
+ // mirrors `/workflow-names` above.
1310
+ app.get("/activity/actions", async (c) => {
1311
+ return c.json({ actions: await db.activity.actions() });
1312
+ });
1218
1313
  app.get("/workflow-runs/:id", async (c) => {
1219
1314
  const id = c.req.param("id");
1220
1315
  const run = await db.runs.getRun(id);
@@ -1399,6 +1494,13 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1399
1494
  }
1400
1495
  }
1401
1496
  }
1497
+ await recordActivityFor(c, db, {
1498
+ action: "workflow.cancel",
1499
+ targetType: "workflow_run",
1500
+ targetId: id,
1501
+ // The COUNT, not the names — `detail` is a summary, not a payload.
1502
+ detail: { workflow: run.workflowName, killedContainers: killed.length },
1503
+ });
1402
1504
  return c.json({ cancelled: id, killedContainers: killed, reapedWorkspace: reaped });
1403
1505
  });
1404
1506
  // Retry a FAILED or CANCELLED workflow run — resume from where it stopped with
@@ -1421,6 +1523,12 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1421
1523
  // Fire-and-forget: restartRun (inside the callback) flips status→running
1422
1524
  // atomically, so a second immediate retry click 400s on the status guard.
1423
1525
  config.retryWorkflow(run, actorFromContext(c) ?? "admin").catch((err) => log.error("Retry failed", { id, err }));
1526
+ await recordActivityFor(c, db, {
1527
+ action: "workflow.retry",
1528
+ targetType: "workflow_run",
1529
+ targetId: id,
1530
+ detail: { workflow: run.workflowName, from: run.status },
1531
+ });
1424
1532
  return c.json({ retrying: id });
1425
1533
  });
1426
1534
  // ── Workflow definitions ─────────────────────────────────────────
@@ -1504,7 +1612,16 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1504
1612
  }
1505
1613
  const current = await db.isWorkflowEnabled(name);
1506
1614
  const next = !current;
1507
- await db.setWorkflowEnabled(name, next, "admin");
1615
+ // `?? "admin"` matches cancel/retry/respond: the column is an existing wire
1616
+ // contract the dashboard renders, so it keeps its literal fallback. The
1617
+ // activity row does NOT — see recordActivityFor.
1618
+ await db.setWorkflowEnabled(name, next, actorFromContext(c) ?? "admin");
1619
+ await recordActivityFor(c, db, {
1620
+ action: "workflow.toggle",
1621
+ targetType: "workflow",
1622
+ targetId: name,
1623
+ detail: { enabled: next },
1624
+ });
1508
1625
  return c.json({ name, enabled: next });
1509
1626
  });
1510
1627
  // Raw YAML file content — preserves comments and formatting for the
@@ -1868,10 +1985,25 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1868
1985
  buildAssetStore.fileFor({ owner, repo, issueKey: key }, doc);
1869
1986
  const metadata = await computeArtifactMetadata(owner, repo, key, doc);
1870
1987
  if (!metadata.editable) {
1988
+ // A refused edit is worth a row: the approval lock is exactly the kind
1989
+ // of guard someone later asks "did anyone try to get around this?".
1990
+ await recordActivityFor(c, db, {
1991
+ action: "artifact.edit",
1992
+ targetType: "repo",
1993
+ targetId: `${owner}/${repo}`,
1994
+ outcome: "denied",
1995
+ detail: { key, doc, reason: "artifact_locked" },
1996
+ });
1871
1997
  return c.json({ error: "artifact_locked", lock: metadata.lock }, 403);
1872
1998
  }
1873
1999
  const body = await c.req.text();
1874
2000
  buildAssetStore.write({ owner, repo, issueKey: key }, doc, body);
2001
+ await recordActivityFor(c, db, {
2002
+ action: "artifact.edit",
2003
+ targetType: "repo",
2004
+ targetId: `${owner}/${repo}`,
2005
+ detail: { key, doc, bytes: body.length },
2006
+ });
1875
2007
  return c.json({ ok: true });
1876
2008
  }
1877
2009
  catch (err) {
@@ -1953,6 +2085,16 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
1953
2085
  });
1954
2086
  }
1955
2087
  }
2088
+ await recordActivityFor(c, db, {
2089
+ action: body.decision === "rejected" ? "approval.reject" : "approval.approve",
2090
+ targetType: "approval",
2091
+ targetId: id,
2092
+ detail: {
2093
+ gate: approval.gate,
2094
+ workflowRunId: approval.workflowRunId,
2095
+ ...(body.reason ? { reason: body.reason } : {}),
2096
+ },
2097
+ });
1956
2098
  return c.json({ status: body.decision });
1957
2099
  });
1958
2100
  // ── Crons ──────────────────────────────────────────────────────
@@ -2083,7 +2225,16 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2083
2225
  const override = await db.getCronOverride(name);
2084
2226
  const currentlyEnabled = override ? override.enabled : true;
2085
2227
  const nextEnabled = !currentlyEnabled;
2086
- await db.setCronOverride(name, { enabled: nextEnabled, updatedBy: "admin" });
2228
+ await db.setCronOverride(name, {
2229
+ enabled: nextEnabled,
2230
+ updatedBy: actorFromContext(c) ?? "admin",
2231
+ });
2232
+ await recordActivityFor(c, db, {
2233
+ action: "cron.toggle",
2234
+ targetType: "cron",
2235
+ targetId: name,
2236
+ detail: { enabled: nextEnabled },
2237
+ });
2087
2238
  // Off is "off BY DEFAULT", not "unregistered" (issue #180): a managed repo
2088
2239
  // may opt itself back into a globally-off cron from its `.lastlight/`, and
2089
2240
  // that is resolved at TICK time — so the tick has to keep running. It just
@@ -2131,7 +2282,13 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2131
2282
  const msg = err instanceof Error ? err.message : String(err);
2132
2283
  return c.json({ error: `invalid schedule: ${msg}` }, 400);
2133
2284
  }
2134
- await db.setCronOverride(name, { schedule, updatedBy: "admin" });
2285
+ await db.setCronOverride(name, { schedule, updatedBy: actorFromContext(c) ?? "admin" });
2286
+ await recordActivityFor(c, db, {
2287
+ action: "config.edit",
2288
+ targetType: "cron",
2289
+ targetId: name,
2290
+ detail: { schedule },
2291
+ });
2135
2292
  const override = await db.getCronOverride(name);
2136
2293
  if (override?.enabled !== false) {
2137
2294
  config.cronScheduler.update({
@@ -2153,6 +2310,12 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2153
2310
  if (!def)
2154
2311
  return c.json({ error: `cron not found: ${name}` }, 404);
2155
2312
  await db.clearCronOverride(name);
2313
+ await recordActivityFor(c, db, {
2314
+ action: "config.edit",
2315
+ targetType: "cron",
2316
+ targetId: name,
2317
+ detail: { cleared: true, schedule: def.schedule },
2318
+ });
2156
2319
  const job = {
2157
2320
  name,
2158
2321
  schedule: def.schedule,
@@ -2176,7 +2339,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2176
2339
  // even for crons that aren't registered — disabled ones, or the polling crons
2177
2340
  // dropped when webhooks are live — which is exactly what manual testing needs.
2178
2341
  // Bypasses the scheduler's per-job overlap guard (acceptable for a manual fire).
2179
- app.post("/crons/:name/trigger", (c) => {
2342
+ app.post("/crons/:name/trigger", async (c) => {
2180
2343
  const name = c.req.param("name");
2181
2344
  const def = getCronWorkflows().find((d) => d.name === name);
2182
2345
  if (!def)
@@ -2216,6 +2379,11 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2216
2379
  [CRON_NAME_KEY]: def.name,
2217
2380
  _cronSource: "manual",
2218
2381
  _cronActor: actor ?? null,
2382
+ // …and HOW they authenticated. Without this the fire's own activity row
2383
+ // could only guess, and guessed `admin` — so a GitHub-authenticated
2384
+ // "Run now" wrote `cron.trigger` as `github` and its paired `cron.fire`
2385
+ // as `admin`, two rows for one action disagreeing about the same person.
2386
+ _cronActorType: actorTypeFromContext(c) ?? null,
2219
2387
  sender: actor,
2220
2388
  };
2221
2389
  const fire = def.handler
@@ -2224,6 +2392,15 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2224
2392
  fire.catch((err) => {
2225
2393
  log.error("Cron trigger failed", { name, err });
2226
2394
  });
2395
+ // The REQUEST, not the fire — `fire` is deliberately not awaited, and the
2396
+ // fire itself writes its own `cron.fire` row from the runner. The pair is
2397
+ // the point: a trigger that never produced a fire is the interesting case.
2398
+ await recordActivityFor(c, db, {
2399
+ action: "cron.trigger",
2400
+ targetType: "cron",
2401
+ targetId: name,
2402
+ detail: def.handler ? { handler: def.handler } : { workflow: def.workflow ?? "" },
2403
+ });
2227
2404
  return c.json({ name, workflow: def.workflow, handler: def.handler, triggered: true });
2228
2405
  });
2229
2406
  // ── Un-stick a pull request — the third retry surface ─────────────────────
@@ -2295,7 +2472,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2295
2472
  // stuck (`dependabot-ci-fix` for a dependency PR, `pr-fix` otherwise)
2296
2473
  // without a second GitHub read to re-derive what the router already decided
2297
2474
  // once. A PR we have never fixed falls back to the configured `pr_fix` route.
2298
- const prior = await db.runs.latestForTrigger([...PR_FIX_SHAPED_WORKFLOWS], prTriggerId(repo, prNumber));
2475
+ const prior = await db.runs.latestForTrigger([...prFixShapedWorkflows()], prTriggerId(repo, prNumber));
2299
2476
  const workflowName = prior?.workflowName ?? getRoutes().github?.pr_fix ?? "pr-fix";
2300
2477
  const state = await resolvePrState(owner, name, prNumber, {
2301
2478
  github,
@@ -2321,6 +2498,20 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2321
2498
  // `retry-requested` row inside the gate, so the ask is parked and will be
2322
2499
  // honoured by the next event — a 200 with `dispatched: false`.
2323
2500
  const refused = !!(disposition.onHold || disposition.runInFlight || disposition.readDegraded);
2501
+ await recordActivityFor(c, db, {
2502
+ action: "pr.retry",
2503
+ targetType: "pr",
2504
+ targetId: `${repo}#${prNumber}`,
2505
+ // A refusal is `denied`; a parked ask that a later event will honour
2506
+ // still happened, so it is `ok` with `dispatched: false` in the detail.
2507
+ outcome: refused ? "denied" : "ok",
2508
+ detail: {
2509
+ workflow: workflowName,
2510
+ dispatched: false,
2511
+ reason: String(disposition.reason ?? "").slice(0, 200),
2512
+ ...(reason ? { note: reason } : {}),
2513
+ },
2514
+ });
2324
2515
  return c.json({
2325
2516
  repo,
2326
2517
  prNumber,
@@ -2348,6 +2539,19 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
2348
2539
  }).catch((err) => {
2349
2540
  log.error("retry failed", { workflow: workflowName, repo, prNumber, err });
2350
2541
  });
2542
+ // The ASK. The run it starts writes its own `workflow.trigger` row from
2543
+ // `dispatchWorkflow` — the same request/execution pair as cron.trigger and
2544
+ // cron.fire, and worth keeping distinct because the two can disagree.
2545
+ await recordActivityFor(c, db, {
2546
+ action: "pr.retry",
2547
+ targetType: "pr",
2548
+ targetId: `${repo}#${prNumber}`,
2549
+ detail: {
2550
+ workflow: workflowName,
2551
+ dispatched: true,
2552
+ ...(reason ? { note: reason } : {}),
2553
+ },
2554
+ });
2351
2555
  return c.json({
2352
2556
  repo,
2353
2557
  prNumber,