@hearsay-tools/squawk 0.18.0-dev.6615 → 0.18.0-dev.6636

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 (33) hide show
  1. package/dist/delegation/routes.d.ts +66 -66
  2. package/dist/delegation/transport.d.ts +62 -62
  3. package/dist/project-migration/steps.js +5 -2
  4. package/dist/project-migration/steps.js.map +1 -1
  5. package/dist/runs/automation-runs.d.ts +26 -0
  6. package/dist/runs/automation-runs.js +69 -0
  7. package/dist/runs/automation-runs.js.map +1 -0
  8. package/dist/runs/conversation-members.d.ts +7 -8
  9. package/dist/runs/conversation-members.js +14 -28
  10. package/dist/runs/conversation-members.js.map +1 -1
  11. package/dist/runs/project-run-connection.js +11 -7
  12. package/dist/runs/project-run-connection.js.map +1 -1
  13. package/dist/runs/run-database-migrations.js +2 -1
  14. package/dist/runs/run-database-migrations.js.map +1 -1
  15. package/dist/runs/run-database-version.d.ts +1 -1
  16. package/dist/runs/run-database-version.js +1 -1
  17. package/dist/runs/run-database.d.ts +10 -3
  18. package/dist/runs/run-database.js +16 -7
  19. package/dist/runs/run-database.js.map +1 -1
  20. package/dist/runs/run-index-rows.d.ts +35 -0
  21. package/dist/runs/run-index-rows.js +51 -0
  22. package/dist/runs/run-index-rows.js.map +1 -0
  23. package/dist/runs/run-indexes.d.ts +7 -0
  24. package/dist/runs/run-indexes.js +8 -0
  25. package/dist/runs/run-indexes.js.map +1 -0
  26. package/dist/runs/run-row.d.ts +3 -0
  27. package/dist/runs/run-row.js +7 -0
  28. package/dist/runs/run-row.js.map +1 -1
  29. package/dist/runs/store.js +5 -10
  30. package/dist/runs/store.js.map +1 -1
  31. package/dist/server/activity-routes.d.ts +23 -23
  32. package/package.json +5 -4
  33. package/scripts/benchmark-automation-lookups.ts +97 -0
@@ -59,6 +59,29 @@ export declare function ciProgressPlugs(demand: ActivityDemand): {
59
59
  export declare function createActivityRoutes(routeDeps: ActivityRouteDeps): import("hono/hono-base").HonoBase<import("hono/types").BlankEnv, {
60
60
  "/workspace/activity": {
61
61
  $get: {
62
+ output: {
63
+ error: string;
64
+ code?: "invalid_input" | undefined;
65
+ };
66
+ outputFormat: "json";
67
+ status: 400;
68
+ input: {
69
+ query: {
70
+ project?: string | undefined;
71
+ };
72
+ };
73
+ } | {
74
+ output: {
75
+ error: string;
76
+ };
77
+ outputFormat: "json";
78
+ status: 404 | 409 | 503;
79
+ input: {
80
+ query: {
81
+ project?: string | undefined;
82
+ };
83
+ };
84
+ } | {
62
85
  output: {
63
86
  generatedAt: string;
64
87
  projects: {
@@ -289,29 +312,6 @@ export declare function createActivityRoutes(routeDeps: ActivityRouteDeps): impo
289
312
  project?: string | undefined;
290
313
  };
291
314
  };
292
- } | {
293
- output: {
294
- error: string;
295
- code?: "invalid_input" | undefined;
296
- };
297
- outputFormat: "json";
298
- status: 400;
299
- input: {
300
- query: {
301
- project?: string | undefined;
302
- };
303
- };
304
- } | {
305
- output: {
306
- error: string;
307
- };
308
- outputFormat: "json";
309
- status: 404 | 409 | 503;
310
- input: {
311
- query: {
312
- project?: string | undefined;
313
- };
314
- };
315
315
  };
316
316
  };
317
317
  }, "/", "/workspace/activity">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hearsay-tools/squawk",
3
- "version": "0.18.0-dev.6615",
3
+ "version": "0.18.0-dev.6636",
4
4
  "description": "Local cockpit for running and tracking AI agent tasks in your repo. Uses your logged-in `claude` CLI and `gh` — zero config, zero database.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -31,6 +31,7 @@
31
31
  "install-as-command": "node scripts/install-as-command.mjs --mode link",
32
32
  "install-as-command:global": "node scripts/install-as-command.mjs --mode global",
33
33
  "uninstall-as-command": "node scripts/install-as-command.mjs --mode uninstall",
34
+ "bench:automation-lookups": "node --import tsx scripts/benchmark-automation-lookups.ts",
34
35
  "bench:conversation-lookup": "node --import tsx scripts/benchmark-conversation-lookup.ts",
35
36
  "bench:family-reconcile": "node --import tsx scripts/benchmark-family-reconcile.ts",
36
37
  "bench:run-store": "node --import tsx scripts/benchmark-run-store.ts",
@@ -62,8 +63,8 @@
62
63
  "devDependencies": {
63
64
  "@babel/parser": "^8.0.8",
64
65
  "@babel/types": "^8.0.8",
65
- "@open-mercato/cezar-api-client": "0.18.0-dev.6615",
66
- "@open-mercato/cezar-contract": "0.18.0-dev.6615",
66
+ "@open-mercato/cezar-api-client": "0.18.0-dev.6636",
67
+ "@open-mercato/cezar-contract": "0.18.0-dev.6636",
67
68
  "@types/node": "^24.19.1",
68
69
  "@types/ws": "^8.18.1",
69
70
  "esbuild": "^0.28.1",
@@ -80,5 +81,5 @@
80
81
  "publishConfig": {
81
82
  "access": "public"
82
83
  },
83
- "gitHead": "14941f4c7896afda08531ee381a80be8d640db38"
84
+ "gitHead": "2fa88363bca7b03bb4daab1debeb26d07dbb3d3d"
84
85
  }
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Automation lookup benchmark: what the automations list and receipt recovery cost as a project's
3
+ * history grows. The list counts every automation's runs (`countAutomationRuns`), and the Tasks
4
+ * pages ask for that list to name each task's automation; receipt recovery looks runs up by receipt
5
+ * (`findRunIdsByAutomationReceipt`). Run it unchanged before and after a change to either lookup.
6
+ *
7
+ * npm run bench:automation-lookups -w @wjarka/cezarion
8
+ * node --import tsx packages/cezar/scripts/benchmark-automation-lookups.ts --runs 1000,4000,10000
9
+ *
10
+ * Flags: --runs (1000,4000,10000) --automations (12) --record-kb (50) --passes (5) --out (a JSON file).
11
+ *
12
+ * Method:
13
+ * - Each size seeds one project's `runs.db` with the store's own row encoding: `--runs` finished
14
+ * tasks of about `--record-kb` each, one in twenty launched by one of `--automations`
15
+ * automations. The defaults follow a busy local project: 4,372 runs, 242 of them from 12
16
+ * automations, 54 KB per record on average.
17
+ * - The store is opened as `serve` opens it. A list is `countAutomationRuns` for every automation;
18
+ * a recovery is one `findRunIdsByAutomationReceipt` call for three receipts.
19
+ * - Times are the median of `--passes` calls, after one warm-up call.
20
+ */
21
+ import { randomUUID } from 'node:crypto';
22
+ import { cpus } from 'node:os';
23
+ import { performance } from 'node:perf_hooks';
24
+ import { parseArgs } from 'node:util';
25
+ import { makeRunRecord } from '@open-mercato/cezar-contract/test-factories.testkit';
26
+ import { benchAt as at, median, runSizes, withSeededStore } from './benchmark-store-fixture.ts';
27
+ import type { RunRecord, RunStore } from '../src/runs/store.ts';
28
+
29
+ export interface AutomationBenchOptions { runs: number; automations: number; recordKb: number; passes: number }
30
+ export interface AutomationBenchRow { runs: number; launched: number; listMs: number; receiptMs: number; counted: number }
31
+
32
+ function records(options: AutomationBenchOptions): { rows: RunRecord[]; receipts: string[] } {
33
+ const task = 'x'.repeat(options.recordKb * 1024), receipts: string[] = [];
34
+ const rows = Array.from({ length: options.runs }, (_, index) => {
35
+ const launched = index % 20 === 0;
36
+ const receiptId = randomUUID();
37
+ if (launched && receipts.length < 3) receipts.push(receiptId);
38
+ return makeRunRecord({ id: randomUUID(), status: 'done', archived: true, task, createdAt: at(index), finishedAt: at(index + 1),
39
+ ...(launched ? { automation: { automationId: `automation-${index % options.automations}`, automationRevision: 1, receiptId,
40
+ event: 'issue.opened', githubUrl: 'https://github.com/o/r/issues/1' } } : {}) });
41
+ });
42
+ return { rows, receipts };
43
+ }
44
+
45
+ /** Seed one temporary project, open its store and time a list and a recovery. */
46
+ export async function measureAutomationLookups(options: AutomationBenchOptions): Promise<AutomationBenchRow> {
47
+ const { rows, receipts } = records(options);
48
+ const ids = Array.from({ length: options.automations }, (_, index) => `automation-${index}`);
49
+ return withSeededStore('cez-bench-automations-', () => rows, async (store: RunStore) => {
50
+ const time = (call: () => unknown) => {
51
+ call();
52
+ const samples: number[] = [];
53
+ for (let i = 0; i < options.passes; i++) { const t = performance.now(); call(); samples.push(performance.now() - t); }
54
+ return Math.round(median(samples));
55
+ };
56
+ const list = () => ids.reduce((sum, id) => sum + store.countAutomationRuns(id), 0);
57
+ return { runs: options.runs, launched: rows.filter(run => run.automation).length, counted: list(),
58
+ listMs: time(list), receiptMs: time(() => store.findRunIdsByAutomationReceipt(receipts)) };
59
+ });
60
+ }
61
+
62
+ export interface AutomationBenchArgs { sizes: number[]; base: Omit<AutomationBenchOptions, 'runs'>; out: string | undefined }
63
+
64
+ /** The command line as one run's settings; throws on a size or count it cannot use. */
65
+ export function parseAutomationBenchArgs(args: string[]): AutomationBenchArgs {
66
+ const { values } = parseArgs({ args, options: {
67
+ runs: { type: 'string', default: '1000,4000,10000' },
68
+ automations: { type: 'string', default: '12' },
69
+ 'record-kb': { type: 'string', default: '50' },
70
+ passes: { type: 'string', default: '5' },
71
+ out: { type: 'string' },
72
+ } });
73
+ const sizes = values.runs.split(',').map(Number);
74
+ const base = { automations: Number(values.automations), recordKb: Number(values['record-kb']), passes: Number(values.passes) };
75
+ const whole = (value: number, min: number) => Number.isInteger(value) && value >= min;
76
+ if (!sizes.every(size => whole(size, 1)) || !whole(base.automations, 1) || !whole(base.recordKb, 0) || !whole(base.passes, 1)) {
77
+ throw new Error('--runs, --automations and --passes take whole numbers >= 1; --record-kb takes a whole number >= 0');
78
+ }
79
+ return { sizes, base, out: values.out };
80
+ }
81
+
82
+ /** The result as a Markdown table under one line naming the settings and the host. */
83
+ export function formatAutomationTable(base: AutomationBenchArgs['base'], rows: readonly AutomationBenchRow[]): string {
84
+ return [
85
+ `${base.automations} automations, record ${base.recordKb} KB, median of ${base.passes} calls, ${cpus().length} cores, Node ${process.version}`,
86
+ '| runs | launched by an automation | automations list ms | receipt recovery ms |',
87
+ '| ---: | ---: | ---: | ---: |',
88
+ ...rows.map(row => `| ${row.runs} | ${row.launched} | ${row.listMs} | ${row.receiptMs} |`),
89
+ ].join('\n');
90
+ }
91
+
92
+ async function main(): Promise<void> {
93
+ const { sizes, base, out } = parseAutomationBenchArgs(process.argv.slice(2));
94
+ await runSizes(sizes, out, runs => measureAutomationLookups({ ...base, runs }), rows => formatAutomationTable(base, rows));
95
+ }
96
+
97
+ if (import.meta.main) await main();