lastlight-core 0.28.1 → 0.29.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 (102) hide show
  1. package/config/default.yaml +25 -0
  2. package/dist/activity.d.ts +19 -0
  3. package/dist/activity.js +28 -0
  4. package/dist/activity.js.map +1 -0
  5. package/dist/admin/activity.d.ts +16 -0
  6. package/dist/admin/activity.js +21 -0
  7. package/dist/admin/activity.js.map +1 -0
  8. package/dist/admin/auth.d.ts +10 -0
  9. package/dist/admin/auth.js +22 -1
  10. package/dist/admin/auth.js.map +1 -1
  11. package/dist/admin/routes.js +211 -7
  12. package/dist/admin/routes.js.map +1 -1
  13. package/dist/config/config.d.ts +8 -0
  14. package/dist/config/config.js +89 -0
  15. package/dist/config/config.js.map +1 -1
  16. package/dist/config/provider-registry.d.ts +57 -0
  17. package/dist/config/provider-registry.js +73 -0
  18. package/dist/config/provider-registry.js.map +1 -0
  19. package/dist/cron/dependabot-discovery.d.ts +1 -1
  20. package/dist/cron/handlers.js +20 -0
  21. package/dist/cron/handlers.js.map +1 -1
  22. package/dist/cron/runner.js +24 -2
  23. package/dist/cron/runner.js.map +1 -1
  24. package/dist/engine/agent-executor.js +19 -6
  25. package/dist/engine/agent-executor.js.map +1 -1
  26. package/dist/engine/chat/chat-runner.d.ts +14 -0
  27. package/dist/engine/chat/chat-runner.js +55 -6
  28. package/dist/engine/chat/chat-runner.js.map +1 -1
  29. package/dist/engine/dispatcher.js +77 -2
  30. package/dist/engine/dispatcher.js.map +1 -1
  31. package/dist/engine/executors/orchestrator.js +4 -2
  32. package/dist/engine/executors/orchestrator.js.map +1 -1
  33. package/dist/engine/fix-harvest.js +2 -2
  34. package/dist/engine/fix-harvest.js.map +1 -1
  35. package/dist/engine/llm.d.ts +1 -1
  36. package/dist/engine/llm.js +18 -11
  37. package/dist/engine/llm.js.map +1 -1
  38. package/dist/engine/pr-decisions.js +3 -3
  39. package/dist/engine/pr-decisions.js.map +1 -1
  40. package/dist/engine/pr-state.d.ts +1 -1
  41. package/dist/engine/pr-state.js +3 -3
  42. package/dist/engine/pr-state.js.map +1 -1
  43. package/dist/index.js +47 -6
  44. package/dist/index.js.map +1 -1
  45. package/dist/sandbox/egress-allowlist.d.ts +20 -8
  46. package/dist/sandbox/egress-allowlist.js +25 -13
  47. package/dist/sandbox/egress-allowlist.js.map +1 -1
  48. package/dist/sandbox/egress-firewall-config.js +3 -3
  49. package/dist/sandbox/egress-firewall-config.js.map +1 -1
  50. package/dist/sandbox/k8s/kubernetes-sandbox.js +2 -2
  51. package/dist/sandbox/k8s/kubernetes-sandbox.js.map +1 -1
  52. package/dist/sandbox/reap.d.ts +1 -1
  53. package/dist/sandbox/reap.js +1 -1
  54. package/dist/sandbox/sandbox.d.ts +8 -0
  55. package/dist/sandbox/sandbox.js +3 -0
  56. package/dist/sandbox/sandbox.js.map +1 -1
  57. package/dist/state/activity-store.d.ts +118 -0
  58. package/dist/state/activity-store.js +173 -0
  59. package/dist/state/activity-store.js.map +1 -0
  60. package/dist/state/data-migrate.js +3 -0
  61. package/dist/state/data-migrate.js.map +1 -1
  62. package/dist/state/db.d.ts +9 -0
  63. package/dist/state/db.js +9 -0
  64. package/dist/state/db.js.map +1 -1
  65. package/dist/state/schema/pg.d.ts +171 -0
  66. package/dist/state/schema/pg.js +16 -0
  67. package/dist/state/schema/pg.js.map +1 -1
  68. package/dist/state/schema/sqlite.d.ts +197 -0
  69. package/dist/state/schema/sqlite.js +30 -0
  70. package/dist/state/schema/sqlite.js.map +1 -1
  71. package/dist/workflows/runner.d.ts +11 -0
  72. package/dist/workflows/runner.js +17 -33
  73. package/dist/workflows/runner.js.map +1 -1
  74. package/dist/workflows/simple.d.ts +3 -4
  75. package/dist/workflows/simple.js +32 -25
  76. package/dist/workflows/simple.js.map +1 -1
  77. package/dist/workflows/target-policy.d.ts +95 -73
  78. package/dist/workflows/target-policy.js +147 -96
  79. package/dist/workflows/target-policy.js.map +1 -1
  80. package/drizzle/pg/0001_brief_gargoyle.sql +15 -0
  81. package/drizzle/pg/meta/0001_snapshot.json +1876 -0
  82. package/drizzle/pg/meta/_journal.json +7 -0
  83. package/drizzle/sqlite/0002_aromatic_vector.sql +15 -0
  84. package/drizzle/sqlite/meta/0002_snapshot.json +1704 -0
  85. package/drizzle/sqlite/meta/_journal.json +8 -1
  86. package/package.json +6 -6
  87. package/workflows/answer.yaml +4 -0
  88. package/workflows/build.yaml +8 -0
  89. package/workflows/demo.yaml +10 -0
  90. package/workflows/dependabot-ci-fix.yaml +7 -0
  91. package/workflows/dependabot-pr-merge.yaml +7 -0
  92. package/workflows/explore.yaml +4 -0
  93. package/workflows/issue-comment.yaml +4 -0
  94. package/workflows/issue-triage.yaml +4 -0
  95. package/workflows/pr-comment.yaml +4 -0
  96. package/workflows/pr-fix.yaml +7 -0
  97. package/workflows/pr-review.yaml +9 -0
  98. package/workflows/qa-test.yaml +10 -0
  99. package/workflows/repo-health.yaml +5 -0
  100. package/workflows/security-feedback.yaml +4 -0
  101. package/workflows/security-review.yaml +4 -0
  102. package/workflows/verify.yaml +10 -0
@@ -1,108 +1,159 @@
1
1
  /**
2
- * Per-target sandbox-workspace provisioning policy — which workflows key their
3
- * workspace by (repo, issue/PR) and how a re-run treats an existing checkout.
2
+ * Per-workflow RUNTIME POLICY — the git-token profile a run is minted, how its
3
+ * sandbox workspace is keyed and refreshed, whether it pre-populates a
4
+ * synthesized branch or pins to a PR's real head ref, and whether it is shaped
5
+ * like `pr-fix`.
4
6
  *
5
- * This is a leaf module (no imports of the runner or the simple entrypoint) so
6
- * both `simple.ts` (taskId keying) and `runner.ts` (`gitSandboxAccessForWorkflow`)
7
- * can read the same source of truth without an import cycle. `simple.ts`
8
- * re-exports these for existing callers (e.g. `src/index.ts`).
9
- */
10
- /**
11
- * Workflows whose workspace is keyed by **(repo, PR)** rather than per-run.
12
- * For these the taskId drops the run-id suffix so re-reviews of the same PR
13
- * (push → `synchronize`, cron PR-review fanout) reuse one sandbox dir — a
14
- * warm `node_modules` + an incremental `git fetch` instead of a fresh
15
- * 1.3G clone + full install each time, and N dirs/PR collapse to 1 (issue
16
- * #107, cutting the #106 churn at its source). Concurrency is held off by
17
- * the dispatcher's `isRunning(skill, triggerId)` guard plus
18
- * `runs.getByTrigger` reuse — two runs never share the dir live; the
19
- * cross-run refresh in `prePopulateWorkspace` resets it cleanly between them.
20
- * `build` is handled by `PER_TARGET_RECREATE_WORKFLOWS` instead — it must not
21
- * *refresh* a stale checkout (that would reset onto the old feature branch);
22
- * it recreates the workspace from the default branch.
7
+ * ## Why this is a workflow's own metadata
8
+ *
9
+ * All five of these used to be literal name tables in compiled core code — a
10
+ * `switch` in `runner.ts` and four `new Set([...])`s here. A workflow that
11
+ * exists only in a deployment OVERLAY could therefore never register itself
12
+ * into any of them: it silently got `git_access: read` (cannot submit a
13
+ * review, cannot push), a cold per-run clone, and no head-ref pinning (it
14
+ * reviews the BASE branch and says nothing about it). The only way to ship a
15
+ * first-class overlay workflow was a core patch naming an arm core does not
16
+ * ship (issue #368).
17
+ *
18
+ * The failure mode is the one `./pr-scope.ts` documents for `pr_scoped`, and
19
+ * this is the same refactor: everything these tables control is invisible in a
20
+ * run's output until it isn't. So each is declared on the workflow — see
21
+ * `git_access` / `workspace` / `prepopulate_synth_branch` /
22
+ * `prepopulate_pr_head_ref` / `pr_fix_shaped` in
23
+ * `packages/workflow-engine/src/core/schema.ts`, which carry the full prose —
24
+ * and read back off the loaded definitions here.
25
+ *
26
+ * ## Resolution
27
+ *
28
+ * Derived from the loader's merged layer stack (built-ins + the deployment
29
+ * overlay) and memoised on `getAssetVersion()`, so an admin asset reload
30
+ * re-derives it without a callback registry — exactly as `prScopedWorkflows()`
31
+ * does. Unlike `pr_scoped` there is NO legacy-name floor: this was a hard
32
+ * cutover, with every built-in YAML declaring its behaviour explicitly and a
33
+ * test pinning the derived policy entry-for-entry. What guards an overlay that
34
+ * forked a workflow before these keys existed is `validateAssets`, which warns
35
+ * when a workflow reachable from a configured `routes.github.*` declares none
36
+ * of them.
37
+ *
38
+ * A name the loader has never heard of — every in-process handler
39
+ * (`chat`, `approval-response`, …), and any caller passing a bare skill name —
40
+ * resolves to {@link DEFAULT_POLICY}, which is what the old tables' `default:`
41
+ * arm and `Set.has() === false` gave it.
42
+ *
43
+ * This stays a LEAF module (it imports the loader, but no importer of it —
44
+ * `runner.ts`, `simple.ts`, the engine — is imported by the loader) so both
45
+ * `simple.ts` (taskId keying) and `runner.ts` (`gitSandboxAccessForWorkflow`)
46
+ * can read one source of truth without an import cycle.
23
47
  */
24
- export const PER_TARGET_REUSE_WORKFLOWS = new Set([
25
- "pr-review",
26
- "pr-fix",
27
- "dependabot-ci-fix",
28
- // dependabot-pr-merge is always single-PR (webhook or the cron's per-PR
29
- // fan-out), so it keys its (checkout-free) run by (repo, PR): a repeated
30
- // `pr.checks_passed` and the daily cron backstop for the same PR dedup onto
31
- // one dir/run rather than stacking.
32
- "dependabot-pr-merge",
33
- ]);
48
+ import { getAssetVersion, listAgentWorkflows } from "./loader.js";
49
+ import { logger } from "../logging/logger.js";
50
+ const log = logger("target-policy");
34
51
  /**
35
- * Workflows shaped like `pr-fix`: dispatched off a PR event, they resolve the
36
- * PR's head branch + failed-check details and push a fix to that branch. The
37
- * dispatcher routes all of them through `handlePrFix` (branch resolution, CI
38
- * failure summary, fork-PR skip), and `dispatchWorkflow` honours the `branch`
39
- * they plumb through context as the pre-populate branch. `dependabot-ci-fix`
40
- * (fix a failing dependency-update PR, then auto-merge trivial ones) is the
41
- * second member. Kept here so the dispatcher and `src/index.ts` share one list.
52
+ * What an undeclared — or unknown — workflow gets.
53
+ *
54
+ * Every field is the value the deleted hardcoded tables produced for a name
55
+ * they did not list, so a workflow that declares nothing behaves exactly as one
56
+ * missing from all five did.
42
57
  */
43
- export const PR_FIX_SHAPED_WORKFLOWS = new Set(["pr-fix", "dependabot-ci-fix"]);
44
- // `DEPENDENCY_WEBHOOK_WORKFLOWS` lived here: the set the dispatcher's
45
- // pre-sandbox idempotency guard was scoped to (skip a PR carrying
46
- // `requires-human`, or one already assessed at its current head SHA). Both
47
- // signals are now fields of the resolved `PrState` snapshot and the guard is a
48
- // pure decision over it (`engine/pr-decisions.ts` → `resolveFixDisposition`),
49
- // which applies to every PR-scoped workflow and every route rather than to two
50
- // workflows on the webhook path — so the set had no readers left. The span the
51
- // snapshot covers is `prScopedWorkflows()` in `./pr-scope.ts`, derived from each
52
- // workflow's own `pr_scoped: true` metadata.
58
+ export const DEFAULT_POLICY = {
59
+ gitAccess: "read",
60
+ workspace: "per-run",
61
+ prepopulateSynthBranch: false,
62
+ prepopulatePrHeadRef: false,
63
+ prFixShaped: false,
64
+ };
65
+ let cached = null;
66
+ let cachedAtVersion = -1;
67
+ function derive() {
68
+ const byName = new Map();
69
+ for (const def of listAgentWorkflows()) {
70
+ byName.set(def.name, {
71
+ gitAccess: def.git_access ?? DEFAULT_POLICY.gitAccess,
72
+ workspace: def.workspace ?? DEFAULT_POLICY.workspace,
73
+ prepopulateSynthBranch: def.prepopulate_synth_branch === true,
74
+ prepopulatePrHeadRef: def.prepopulate_pr_head_ref === true,
75
+ prFixShaped: def.pr_fix_shaped === true,
76
+ });
77
+ }
78
+ return byName;
79
+ }
80
+ function policies() {
81
+ const version = getAssetVersion();
82
+ if (cached && cachedAtVersion === version)
83
+ return cached;
84
+ let byName;
85
+ try {
86
+ byName = derive();
87
+ }
88
+ catch (err) {
89
+ // A loader that cannot read its workflows must not take the process with
90
+ // it: every lookup then falls through to DEFAULT_POLICY, the least
91
+ // privileged answer (read token, cold per-run workspace, no pinning).
92
+ log.warn("Could not read the workflow definitions — every workflow falls back to the default policy", { err });
93
+ byName = new Map();
94
+ }
95
+ cached = byName;
96
+ cachedAtVersion = version;
97
+ return cached;
98
+ }
53
99
  /**
54
- * Workflows whose per-target workspace is **recreated from the default branch**
55
- * on a fresh run rather than refreshed onto an existing feature branch. Like
56
- * `PER_TARGET_REUSE_WORKFLOWS`, these key the taskId by (repo, issue) only (no
57
- * run-id suffix) so a re-run lands on the same dir — but a *different*-run
58
- * marker triggers a delete + fresh clone off the default branch, not a
59
- * `git fetch`/reset of the (stale) feature branch. This makes an incomplete
60
- * `build` disposable: re-triggering it starts again from current `main`
61
- * (issue #153). A genuine *resume* of the same run (approval gate) still
62
- * preserves the workspace via the same-run marker — the architect's `plan.md`
63
- * survives. Concurrency is held off by the dispatcher's
64
- * `isRunning(skill, triggerId)` guard, so the delete only ever hits a leftover
65
- * from a finished/abandoned run.
100
+ * The resolved policy for one workflow, by name.
101
+ *
102
+ * Cheap to call — memoised per asset version, and every caller is on a dispatch
103
+ * path that already resolves config.
66
104
  */
67
- export const PER_TARGET_RECREATE_WORKFLOWS = new Set(["build"]);
105
+ export function workflowTargetPolicy(workflowName) {
106
+ return policies().get(workflowName) ?? DEFAULT_POLICY;
107
+ }
108
+ /** What the GitHub token minted for this workflow's sandbox may do. */
109
+ export function gitAccessFor(workflowName) {
110
+ return workflowTargetPolicy(workflowName).gitAccess;
111
+ }
112
+ /** Is this workflow's workspace keyed by (repo, target) rather than per-run? */
113
+ export function isPerTargetWorkspace(workflowName) {
114
+ return workflowTargetPolicy(workflowName).workspace !== "per-run";
115
+ }
116
+ /** Keyed by (repo, target) and REFRESHED across runs (`per-target-reuse`). */
117
+ export function isPerTargetReuse(workflowName) {
118
+ return workflowTargetPolicy(workflowName).workspace === "per-target-reuse";
119
+ }
68
120
  /**
69
- * Workflows that synthesize their own `lastlight/N-slug` branch (which doesn't
70
- * exist on the remote at dispatch time) yet should still pre-populate the
71
- * sandbox: the agent's cwd becomes the repo root (no `git clone`/`cd`), and —
72
- * for the read-only `verify`/`qa-test` runs — server-mode artifacts the agent
73
- * writes to `.lastlight/<key>/` (e.g. browser-QA screenshots) land where
74
- * `serverArtifacts()` harvests them instead of being orphaned a level up.
75
- * `build` was the original member; verify/qa-test were added for the harvest
76
- * fix, and `demo` for the same reason (its `demo.mp4` is written under
77
- * `.lastlight/<key>/` and harvested into the Artifacts store). For a fresh
78
- * (issue-scoped) dispatch the dispatcher leaves `prePopulateBranch` unset and
79
- * the missing-branch fallback in `prePopulateWorkspace` clones the default
80
- * branch — correct for `build`/`demo`, which *create* the synth branch off the
81
- * default. But when the *same* workflow runs against an existing PR, the synth
82
- * `lastlight/<prNumber>-<title-slug>` name won't match the PR's real head ref
83
- * (named after the originating issue), so the fallback would clone the default
84
- * branch and test/demo code that lacks the PR — see
85
- * `PR_HEADREF_PREPOPULATE_WORKFLOWS`.
121
+ * Keyed by (repo, target) and RECREATED from the default branch on a fresh run
122
+ * (`per-target-recreate`) — read as `recreateFromBase` by the sandbox.
86
123
  */
87
- export const PREPOPULATE_SYNTH_WORKFLOWS = new Set(["build", "verify", "qa-test", "demo"]);
124
+ export function isPerTargetRecreate(workflowName) {
125
+ return workflowTargetPolicy(workflowName).workspace === "per-target-recreate";
126
+ }
127
+ /** Pre-populate the sandbox even though this workflow's branch is synthesized. */
128
+ export function prepopulatesSynthBranch(workflowName) {
129
+ return workflowTargetPolicy(workflowName).prepopulateSynthBranch;
130
+ }
131
+ /** Against a real PR, pin the pre-clone to the PR's actual head ref. */
132
+ export function prepopulatesPrHeadRef(workflowName) {
133
+ return workflowTargetPolicy(workflowName).prepopulatePrHeadRef;
134
+ }
135
+ /** Is this workflow dispatched through `handlePrFix`? */
136
+ export function isPrFixShaped(workflowName) {
137
+ return workflowTargetPolicy(workflowName).prFixShaped;
138
+ }
88
139
  /**
89
- * The subset of PR-scoped read workflows the dispatcher pins to the PR's *real*
90
- * head ref (via `getPullRequest(...).head.ref`) before pre-populating, instead
91
- * of letting them fall back to the synthesized `lastlight/N-<title-slug>` name.
92
- * Each of these is meaningful only against an existing PR, and the synth name
93
- * never matches the PR's actual branch (which is named after the originating
94
- * issue, e.g. `lastlight/14-…` for a PR #15). Without this pinning:
95
- * - `qa-test` / `verify` QA the *base* branch and report the PR's feature
96
- * missing — a false-negative result.
97
- * - `demo`'s "after" collapses onto the default branch, matching "before".
98
- * `pr-fix` is handled separately (it plumbs `branch` through context for the
99
- * architect/executor to push to). See the resolution block in
100
- * `dispatchWorkflow` (src/index.ts).
140
+ * Every `pr_fix_shaped` workflow, by name — the fix FAMILY.
141
+ *
142
+ * Kept as a set (not just the predicate) because several callers need to
143
+ * ENUMERATE it rather than test one name: the shared per-PR workspace key, the
144
+ * fix ledger's per-family scan (`engine/pr-state.ts`) and the admin PR-retry
145
+ * route's `latestForTrigger` all ask "which of these last worked this PR".
101
146
  */
102
- export const PR_HEADREF_PREPOPULATE_WORKFLOWS = new Set([
103
- "pr-review",
104
- "demo",
105
- "qa-test",
106
- "verify",
107
- ]);
147
+ export function prFixShapedWorkflows() {
148
+ const names = new Set();
149
+ for (const [name, policy] of policies())
150
+ if (policy.prFixShaped)
151
+ names.add(name);
152
+ return names;
153
+ }
154
+ /** Drop the memo. Tests only — production invalidates on `getAssetVersion()`. */
155
+ export function __resetTargetPolicyCacheForTest() {
156
+ cached = null;
157
+ cachedAtVersion = -1;
158
+ }
108
159
  //# sourceMappingURL=target-policy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"target-policy.js","sourceRoot":"","sources":["../../src/workflows/target-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAC;IAChD,WAAW;IACX,QAAQ;IACR,mBAAmB;IACnB,wEAAwE;IACxE,yEAAyE;IACzE,4EAA4E;IAC5E,oCAAoC;IACpC,qBAAqB;CACtB,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC;AAEhF,sEAAsE;AACtE,kEAAkE;AAClE,2EAA2E;AAC3E,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,+EAA+E;AAC/E,iFAAiF;AACjF,6CAA6C;AAE7C;;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CAAC,YAAoB;IACnD,OAAO,oBAAoB,CAAC,YAAY,CAAC,CAAC,SAAS,KAAK,kBAAkB,CAAC;AAC7E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,YAAoB;IACtD,OAAO,oBAAoB,CAAC,YAAY,CAAC,CAAC,SAAS,KAAK,qBAAqB,CAAC;AAChF,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,uBAAuB,CAAC,YAAoB;IAC1D,OAAO,oBAAoB,CAAC,YAAY,CAAC,CAAC,sBAAsB,CAAC;AACnE,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,qBAAqB,CAAC,YAAoB;IACxD,OAAO,oBAAoB,CAAC,YAAY,CAAC,CAAC,oBAAoB,CAAC;AACjE,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,aAAa,CAAC,YAAoB;IAChD,OAAO,oBAAoB,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC;AACxD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,QAAQ,EAAE;QAAE,IAAI,MAAM,CAAC,WAAW;YAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjF,OAAO,KAAK,CAAC;AACf,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,+BAA+B;IAC7C,MAAM,GAAG,IAAI,CAAC;IACd,eAAe,GAAG,CAAC,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,15 @@
1
+ CREATE TABLE "activity_log" (
2
+ "id" text PRIMARY KEY NOT NULL,
3
+ "created_at" text NOT NULL,
4
+ "actor_login" text,
5
+ "actor_type" text,
6
+ "action" text NOT NULL,
7
+ "target_type" text,
8
+ "target_id" text,
9
+ "outcome" text NOT NULL,
10
+ "detail" jsonb
11
+ );
12
+ --> statement-breakpoint
13
+ CREATE INDEX "idx_activity_created" ON "activity_log" USING btree ("created_at" DESC NULLS LAST);--> statement-breakpoint
14
+ CREATE INDEX "idx_activity_actor_created" ON "activity_log" USING btree ("actor_login","created_at" DESC NULLS LAST);--> statement-breakpoint
15
+ CREATE INDEX "idx_activity_target" ON "activity_log" USING btree ("target_type","target_id");