@sixb/cli 0.1.19 → 0.1.21

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 (65) hide show
  1. package/README.md +26 -27
  2. package/dist/commands/api.d.ts +0 -1
  3. package/dist/commands/api.d.ts.map +1 -1
  4. package/dist/commands/app.d.ts.map +1 -1
  5. package/dist/commands/build.d.ts.map +1 -1
  6. package/dist/commands/check.d.ts.map +1 -1
  7. package/dist/commands/dev-runner.d.ts +12 -1
  8. package/dist/commands/dev-runner.d.ts.map +1 -1
  9. package/dist/commands/lake-check.d.ts.map +1 -1
  10. package/dist/commands/lake-cleanup.d.ts +2 -0
  11. package/dist/commands/lake-cleanup.d.ts.map +1 -1
  12. package/dist/commands/worker-group.d.ts +1 -0
  13. package/dist/commands/worker-group.d.ts.map +1 -1
  14. package/dist/commands/worker.d.ts +1 -0
  15. package/dist/commands/worker.d.ts.map +1 -1
  16. package/dist/lib/browser-topology.d.ts +9 -33
  17. package/dist/lib/browser-topology.d.ts.map +1 -1
  18. package/dist/lib/command-line.d.ts +8 -8
  19. package/dist/lib/command-line.d.ts.map +1 -1
  20. package/dist/lib/deploy-release.d.ts.map +1 -1
  21. package/dist/lib/dev-supervisor.d.ts.map +1 -1
  22. package/dist/lib/dev-watch.d.ts +1 -1
  23. package/dist/lib/dev-watch.d.ts.map +1 -1
  24. package/dist/lib/production-roles.d.ts +5 -10
  25. package/dist/lib/production-roles.d.ts.map +1 -1
  26. package/dist/lib/production.d.ts +1 -2
  27. package/dist/lib/production.d.ts.map +1 -1
  28. package/dist/lib/role-view.d.ts +2 -3
  29. package/dist/lib/role-view.d.ts.map +1 -1
  30. package/dist/lib/runtime.d.ts +9 -0
  31. package/dist/lib/runtime.d.ts.map +1 -1
  32. package/dist/lib/worker-concurrency.d.ts +5 -0
  33. package/dist/lib/worker-concurrency.d.ts.map +1 -1
  34. package/dist/lib/worker-registry.d.ts +1 -0
  35. package/dist/lib/worker-registry.d.ts.map +1 -1
  36. package/dist/ui/index.d.ts +16 -5
  37. package/dist/ui/index.d.ts.map +1 -1
  38. package/package.json +16 -16
  39. package/src/commands/api.tsx +1 -5
  40. package/src/commands/app.tsx +5 -7
  41. package/src/commands/build.tsx +14 -31
  42. package/src/commands/check.tsx +50 -4
  43. package/src/commands/dev-runner.tsx +43 -47
  44. package/src/commands/lake-check.tsx +15 -2
  45. package/src/commands/lake-cleanup.tsx +11 -0
  46. package/src/commands/worker-group.tsx +4 -1
  47. package/src/commands/worker.tsx +4 -1
  48. package/src/index.tsx +3 -14
  49. package/src/lib/browser-topology.ts +28 -135
  50. package/src/lib/command-line.ts +26 -18
  51. package/src/lib/deploy-release.ts +0 -3
  52. package/src/lib/dev-supervisor.ts +7 -6
  53. package/src/lib/dev-watch.ts +8 -8
  54. package/src/lib/production-roles.ts +5 -7
  55. package/src/lib/production.ts +3 -8
  56. package/src/lib/profiles.ts +1 -1
  57. package/src/lib/role-lifecycle.ts +2 -2
  58. package/src/lib/role-view.ts +2 -3
  59. package/src/lib/runtime.ts +19 -0
  60. package/src/lib/worker-concurrency.ts +11 -0
  61. package/src/lib/worker-registry.ts +5 -1
  62. package/src/ui/index.tsx +46 -19
  63. package/dist/commands/atlas.d.ts +0 -9
  64. package/dist/commands/atlas.d.ts.map +0 -1
  65. package/src/commands/atlas.tsx +0 -71
@@ -83,7 +83,7 @@ export function builtAppOutdir(buildOutdir: string): string {
83
83
  return resolve(buildOutdir, "app")
84
84
  }
85
85
 
86
- export async function hasBuiltCustomApp(appOutdir: string): Promise<boolean> {
86
+ export async function hasBuiltApp(appOutdir: string): Promise<boolean> {
87
87
  const shells = await Promise.all(
88
88
  ["index.html", "shared-index.html"].map((file) =>
89
89
  stat(resolve(appOutdir, file))
@@ -94,10 +94,6 @@ export async function hasBuiltCustomApp(appOutdir: string): Promise<boolean> {
94
94
  return shells.every(Boolean)
95
95
  }
96
96
 
97
- export function builtAtlasOutdir(buildOutdir: string): string {
98
- return resolve(buildOutdir, "atlas")
99
- }
100
-
101
97
  function isDefaultBuildEntry(entry: string): boolean {
102
98
  return entry.includes(`${sep}.sixb${sep}dist${sep}`)
103
99
  }
@@ -107,9 +103,8 @@ async function isCustomBuildOutdirEntry(entry: string, entryDir: string): Promis
107
103
  return false
108
104
  }
109
105
 
110
- const hasBuiltAtlas = await stat(resolve(entryDir, "atlas"))
106
+ // `sixb build` always writes the app next to the entry.
107
+ return await stat(builtAppOutdir(entryDir))
111
108
  .then((info) => info.isDirectory())
112
109
  .catch(() => false)
113
-
114
- return hasBuiltAtlas
115
110
  }
@@ -167,7 +167,7 @@ export async function resolveProfile(input: ResolveProfileInput = {}): Promise<R
167
167
  }
168
168
 
169
169
  return {
170
- apiUrl: "http://localhost:3002",
170
+ apiUrl: "http://localhost:3001",
171
171
  ...(explicitToken ? { token: explicitToken, tokenSource: "--token" as const } : {}),
172
172
  source: "default",
173
173
  }
@@ -1,7 +1,7 @@
1
1
  import { appendFileSync } from "node:fs"
2
2
 
3
- // Kept apart from `runtime.ts`, which imports every worker package: `atlas` and `app` serve static
4
- // assets for as long as they run and must not hold that module graph to reuse these two helpers.
3
+ // Kept apart from `runtime.ts`, which imports every worker package: `app` serves static assets for
4
+ // as long as it runs and must not hold that module graph to reuse these two helpers.
5
5
 
6
6
  export async function stopQuietly(stopFn: (() => Promise<void>) | undefined | null): Promise<void> {
7
7
  if (!stopFn) return
@@ -13,9 +13,8 @@ export interface RoleView {
13
13
  /**
14
14
  * How a long-running role reports itself: the Ink panels in a terminal, plain lines in a log.
15
15
  *
16
- * Ink's layout engine keeps about 45 MB for the life of the process once it is imported. `atlas`
17
- * and `app` run under a supervisor and serve static files, so outside a terminal they never load
18
- * it.
16
+ * Ink's layout engine keeps about 45 MB for the life of the process once it is imported. `app`
17
+ * runs under a supervisor and serves static files, so outside a terminal it never loads it.
19
18
  *
20
19
  * Call this before the role sets NODE_ENV. Bun compiles JSX for the mode the process started in,
21
20
  * and React loaded after the change cannot run it: the panels then render nothing, or throw. Ink
@@ -8,6 +8,7 @@ import {
8
8
  ProjectionRunDispatcher,
9
9
  } from "@sixb/core/internal/projections"
10
10
  import { setApiPublicOrigin } from "@sixb/core/internal/runtime"
11
+ import { checkPipelineMarkings, getAppliedMarkings } from "@sixb/core/internal/security"
11
12
  import { SyncRunDispatcher } from "@sixb/core/internal/syncs"
12
13
  import type { Worker } from "@sixb/core/internal/workers"
13
14
  import { WorkflowRunDispatcher } from "@sixb/core/internal/workflows"
@@ -61,6 +62,7 @@ export interface StartSixbRuntimeOptions {
61
62
  readonly agentApiBaseUrl?: string
62
63
  readonly agentTurnTimeoutMs?: number
63
64
  readonly workerConcurrency?: WorkerConcurrency
65
+ readonly vectorConcurrency?: number
64
66
  }
65
67
 
66
68
  export interface RuntimeApiServer {
@@ -107,6 +109,21 @@ export async function checkRuntimeLakeDefinitions(sixb: LoadedSixbHost): Promise
107
109
  })
108
110
  }
109
111
 
112
+ /** Derives the markings SQL steps give their outputs and checks every projection against them. */
113
+ export async function checkRuntimePipelineMarkings(sixb: LoadedSixbHost): Promise<void> {
114
+ await checkPipelineMarkings({ definitions: sixb.definitions, lakeStorage: sixb.lakeStorage })
115
+ }
116
+
117
+ /**
118
+ * What the dataset versions projections applied add to the code's markings, one line per
119
+ * projection: properties that keep a marking, and object types or links readers cannot read,
120
+ * until the projection applies a version the code allows. Reads the projections' active sources.
121
+ */
122
+ export async function readAppliedMarkingNotices(sixb: LoadedSixbHost): Promise<readonly string[]> {
123
+ const { notices } = await getAppliedMarkings(sixb).current()
124
+ return notices.map((notice) => notice.message)
125
+ }
126
+
110
127
  export async function stopSixbProviders(sixb: LoadedSixbHost): Promise<void> {
111
128
  // Actions run inside the request that asked for them, and a client that disconnects does not stop
112
129
  // them: refuse new ones and give those in flight, and the effects they start, time to finish
@@ -261,6 +278,7 @@ export async function startSixbRuntime(
261
278
  // Own providers from the first startup phase, including preflight failures.
262
279
  await migrateRuntimeStorage(sixb)
263
280
  await checkRuntimeLakeDefinitions(sixb)
281
+ await checkRuntimePipelineMarkings(sixb)
264
282
  rulesRuntime = await startRulesRuntime(sixb)
265
283
  rulesWorker = rulesRuntime.rulesWorker
266
284
 
@@ -280,6 +298,7 @@ export async function startSixbRuntime(
280
298
  if (projectionCount > 0) {
281
299
  projectionWorker = new ProjectionWorker(sixb, {
282
300
  concurrency: options.workerConcurrency?.projection,
301
+ vectorConcurrency: options.vectorConcurrency,
283
302
  })
284
303
  await projectionWorker.start()
285
304
  }
@@ -47,6 +47,17 @@ export function resolveWorkerConcurrency(values: readonly string[] = []): Worker
47
47
  return resolved
48
48
  }
49
49
 
50
+ /**
51
+ * Resolve the projection worker's concurrent embedding calls. `undefined` leaves the worker's
52
+ * built-in default in authority.
53
+ */
54
+ export function resolveVectorConcurrency(value: string | undefined): number | undefined {
55
+ const configured = value?.trim() ?? nonblank(process.env.SIXB_VECTOR_CONCURRENCY)
56
+ if (configured === undefined) return undefined
57
+
58
+ return parseConcurrency(configured, "--vector-concurrency or SIXB_VECTOR_CONCURRENCY")
59
+ }
60
+
50
61
  function parseWorkerConcurrencyEntry(value: string): {
51
62
  readonly workerType: WorkerType
52
63
  readonly concurrency: number
@@ -19,6 +19,7 @@ export interface WorkerCreationOptions {
19
19
  readonly agentApiBaseUrl?: string
20
20
  readonly agentTurnTimeoutMs?: number
21
21
  readonly workerConcurrency?: WorkerConcurrency
22
+ readonly vectorConcurrency?: number
22
23
  }
23
24
 
24
25
  interface WorkerFactory {
@@ -62,7 +63,10 @@ const workerFactories: Record<WorkerType, WorkerFactory> = {
62
63
  },
63
64
  projection: {
64
65
  create: (sixb, options) =>
65
- new ProjectionWorker(sixb, { concurrency: options.workerConcurrency?.projection }),
66
+ new ProjectionWorker(sixb, {
67
+ concurrency: options.workerConcurrency?.projection,
68
+ vectorConcurrency: options.vectorConcurrency,
69
+ }),
66
70
  },
67
71
  workflow: {
68
72
  create: (sixb, options) =>
package/src/ui/index.tsx CHANGED
@@ -44,9 +44,9 @@ export async function renderCliError(
44
44
  )
45
45
  }
46
46
 
47
- // The entrypoint and the browser roles render through these rather than JSX of their own: a module
48
- // with JSX loads React as soon as it is evaluated, and `atlas` and `app` load neither React nor
49
- // Ink outside a terminal.
47
+ // The entrypoint and the app role render through these rather than JSX of their own: a module
48
+ // with JSX loads React as soon as it is evaluated, and `app` loads neither React nor Ink outside a
49
+ // terminal.
50
50
 
51
51
  export async function renderVersion(version: string): Promise<void> {
52
52
  await renderStatic(<VersionView version={version} />)
@@ -481,7 +481,6 @@ export function DevView({
481
481
  apiUrl,
482
482
  apiDocsUrl,
483
483
  wsUrl,
484
- uiUrl,
485
484
  appUrl,
486
485
  workers = [],
487
486
  warnings = [],
@@ -490,8 +489,8 @@ export function DevView({
490
489
  apiUrl: string
491
490
  apiDocsUrl: string
492
491
  wsUrl: string
493
- uiUrl: string | null
494
- appUrl?: string | null
492
+ /** `null` when the app could not start; a warning says why. */
493
+ appUrl: string | null
495
494
  workers?: readonly { readonly type: string; readonly concurrency: number }[]
496
495
  warnings?: readonly string[]
497
496
  }) {
@@ -500,22 +499,15 @@ export function DevView({
500
499
  { label: "API docs", value: apiDocsUrl },
501
500
  { label: "Events", value: wsUrl },
502
501
  ]
503
- if (uiUrl) {
504
- serverItems.push({ label: "Atlas UI", value: uiUrl })
505
- }
506
502
 
507
503
  return (
508
504
  <Box flexDirection="column">
509
505
  <Text bold>sixb dev</Text>
510
506
  <Text dimColor>{name}</Text>
511
507
  <Spacer />
508
+ <ServicePanel name="App" items={[{ label: "URL", value: appUrl ?? "not running" }]} />
509
+ <Spacer />
512
510
  <ServicePanel name="Server" items={serverItems} />
513
- {appUrl ? (
514
- <>
515
- <Spacer />
516
- <ServicePanel name="Custom app" items={[{ label: "URL", value: appUrl }]} />
517
- </>
518
- ) : null}
519
511
  {workers.length > 0 ? (
520
512
  <>
521
513
  <Spacer />
@@ -667,6 +659,7 @@ export function CheckView({
667
659
  broker,
668
660
  queues,
669
661
  projectValidation,
662
+ markings,
670
663
  ontology,
671
664
  warnings,
672
665
  }: {
@@ -676,12 +669,20 @@ export function CheckView({
676
669
  broker: { ok: boolean; message?: string }
677
670
  queues: { ok: boolean; message?: string }
678
671
  projectValidation?: { ok: boolean; message?: string }
672
+ /**
673
+ * The pipeline markings preflight: what SQL steps derive, checked against projections. A warning
674
+ * reports projections whose applied version adds markings the code no longer declares.
675
+ */
676
+ markings?: { ok: boolean; warning?: boolean; message?: string }
679
677
  ontology?: { enabled: boolean; source: string; errors: number; warnings: number }
680
678
  warnings: readonly string[]
681
679
  }) {
682
680
  const validation = projectValidation ?? { ok: true, message: "ok" }
683
681
  const ontologyOk = (ontology?.errors ?? 0) === 0
684
- const allOk = [storage, timeseries, broker, queues, validation].every((row) => row.ok)
682
+ const markingsCheck = markings ?? { ok: true, message: "ok" }
683
+ const allOk = [storage, timeseries, broker, queues, validation, markingsCheck].every(
684
+ (row) => row.ok
685
+ )
685
686
  const healthy = allOk && ontologyOk
686
687
 
687
688
  // The message wins when there is one, pass or fail: a probe that succeeded still says which
@@ -690,8 +691,9 @@ export function CheckView({
690
691
  return row.message ?? (row.ok ? "ok" : "failed")
691
692
  }
692
693
 
693
- function statusColor(ok: boolean): string {
694
- return ok ? "green" : "red"
694
+ function statusColor(ok: boolean, warning = false): string {
695
+ if (!ok) return "red"
696
+ return warning ? "yellow" : "green"
695
697
  }
696
698
 
697
699
  return (
@@ -723,6 +725,12 @@ export function CheckView({
723
725
  <Text dimColor>{padLabel("Project", 14)}</Text>
724
726
  <Text color={statusColor(validation.ok)}>{statusText(validation)}</Text>
725
727
  </Text>
728
+ <Text>
729
+ <Text dimColor>{padLabel("Markings", 14)}</Text>
730
+ <Text color={statusColor(markingsCheck.ok, markingsCheck.warning)}>
731
+ {statusText(markingsCheck)}
732
+ </Text>
733
+ </Text>
726
734
  </Box>
727
735
  {ontology ? (
728
736
  <>
@@ -821,7 +829,15 @@ export function DbMigrateView({
821
829
  )
822
830
  }
823
831
 
824
- export function LakeCheckView({ projectId, status }: { projectId: string; status: "ok" }) {
832
+ export function LakeCheckView({
833
+ projectId,
834
+ status,
835
+ warnings = [],
836
+ }: {
837
+ projectId: string
838
+ status: "ok"
839
+ warnings?: readonly string[]
840
+ }) {
825
841
  return (
826
842
  <Box flexDirection="column">
827
843
  <Text color="green" bold>
@@ -830,6 +846,13 @@ export function LakeCheckView({ projectId, status }: { projectId: string; status
830
846
  <Text dimColor>{projectId}</Text>
831
847
  <Spacer />
832
848
  <KeyValueList items={[{ label: "Lake", value: status }]} />
849
+ {warnings.length > 0 ? (
850
+ <>
851
+ <Spacer />
852
+ <SectionTitle>Warnings</SectionTitle>
853
+ <BulletList items={warnings} />
854
+ </>
855
+ ) : null}
833
856
  </Box>
834
857
  )
835
858
  }
@@ -1298,6 +1321,7 @@ export interface LakeCleanupReport {
1298
1321
  readonly expireOlderThan: string
1299
1322
  readonly deleteOlderThan: string
1300
1323
  readonly snapshots: number
1324
+ readonly keptSnapshots?: number
1301
1325
  readonly oldFiles: number
1302
1326
  readonly orphanedFiles: number
1303
1327
  }
@@ -1322,6 +1346,9 @@ export function LakeCleanupView({
1322
1346
  { label: "Expire older than", value: report.expireOlderThan },
1323
1347
  { label: "Delete older than", value: report.deleteOlderThan },
1324
1348
  { label: "Snapshots", value: String(report.snapshots) },
1349
+ ...(report.keptSnapshots === undefined
1350
+ ? []
1351
+ : [{ label: "Kept snapshots", value: String(report.keptSnapshots) }]),
1325
1352
  { label: "Old files", value: String(report.oldFiles) },
1326
1353
  { label: "Orphaned files", value: String(report.orphanedFiles) },
1327
1354
  ]}
@@ -1,9 +0,0 @@
1
- export interface AtlasOptions {
2
- entry?: string;
3
- port?: string;
4
- host?: string;
5
- apiPublicOrigin?: string;
6
- atlasPublicOrigin?: string;
7
- }
8
- export declare function runAtlas(options?: AtlasOptions): Promise<void>;
9
- //# sourceMappingURL=atlas.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"atlas.d.ts","sourceRoot":"","sources":["../../src/commands/atlas.tsx"],"names":[],"mappings":"AAOA,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,wBAAsB,QAAQ,CAAC,OAAO,GAAE,YAAiB,iBAuDxD"}
@@ -1,71 +0,0 @@
1
- import { basename } from "node:path"
2
- import { type AtlasAppServer, createAtlasApp } from "@sixb/atlas"
3
- import { resolveBrowserTopology, servedUrl } from "../lib/browser-topology"
4
- import { builtAtlasOutdir, resolveProductionPaths, resolveRuntimeEntry } from "../lib/production"
5
- import { runUntilSignal, stopQuietly } from "../lib/role-lifecycle"
6
- import { loadRoleView } from "../lib/role-view"
7
-
8
- export interface AtlasOptions {
9
- entry?: string
10
- port?: string
11
- host?: string
12
- apiPublicOrigin?: string
13
- atlasPublicOrigin?: string
14
- }
15
-
16
- export async function runAtlas(options: AtlasOptions = {}) {
17
- // Before NODE_ENV changes: see loadRoleView.
18
- const view = await loadRoleView()
19
- process.env.NODE_ENV = "production"
20
-
21
- const entry = await resolveRuntimeEntry({ entry: options.entry })
22
- const { projectRoot, buildOutdir } = await resolveProductionPaths(entry)
23
- const app = view.startup({
24
- title: "Starting sixb atlas",
25
- subtitle: entry,
26
- status: "Starting Atlas",
27
- })
28
-
29
- let atlasServer: AtlasAppServer | null = null
30
-
31
- try {
32
- const topology = resolveBrowserTopology({
33
- role: "atlas",
34
- host: options.host,
35
- port: options.port,
36
- apiPublicOrigin: options.apiPublicOrigin,
37
- atlasPublicOrigin: options.atlasPublicOrigin,
38
- })
39
-
40
- const atlas = createAtlasApp({
41
- apiBaseUrl: topology.apiPublicOrigin,
42
- audience: "atlas",
43
- // No authEnabled: the page asks the API whether the project uses auth, so serving the
44
- // bundle never loads the project.
45
- })
46
- atlasServer = await atlas.start({
47
- host: topology.host,
48
- port: topology.atlasPort,
49
- development: false,
50
- outdir: builtAtlasOutdir(buildOutdir),
51
- })
52
-
53
- app.started({
54
- title: "Sixb Atlas started",
55
- name: basename(projectRoot),
56
- serviceName: "Atlas",
57
- items: [{ label: "URL", value: servedUrl(topology) }],
58
- })
59
-
60
- await runUntilSignal(async () => {
61
- app.unmount()
62
- console.log("\nShutting down atlas...")
63
- await stopQuietly(() => atlasServer?.stop() ?? Promise.resolve())
64
- })
65
- } catch (error) {
66
- app.unmount()
67
- await stopQuietly(() => atlasServer?.stop() ?? Promise.resolve())
68
- await view.error(error)
69
- process.exit(1)
70
- }
71
- }