@ontrails/trails 1.0.0-beta.41 → 1.0.0-beta.43

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.
@@ -44,6 +44,13 @@ const contractReleaseFactSchema = z.object({
44
44
  workspacePath: z.string().optional(),
45
45
  });
46
46
 
47
+ const packageRouteReleaseFactSchema = z.object({
48
+ kind: z.enum(['classified', 'single']),
49
+ sourcePackage: z.string(),
50
+ targetPackage: z.string().optional(),
51
+ transitionId: z.string(),
52
+ });
53
+
47
54
  const releaseCheckOutputSchema = z.object({
48
55
  activePackageChangesetsWithoutReleaseFacts: z.array(z.string()).readonly(),
49
56
  affectedPackages: z.array(z.string()).readonly(),
@@ -55,6 +62,7 @@ const releaseCheckOutputSchema = z.object({
55
62
  formatted: z.string(),
56
63
  matchedRuleIds: z.array(z.string()).readonly(),
57
64
  noReleaseOverride: z.boolean(),
65
+ packageRouteFacts: z.array(packageRouteReleaseFactSchema).readonly(),
58
66
  passed: z.boolean(),
59
67
  releaseNone: z.boolean(),
60
68
  uncoveredContractFacts: z.array(contractReleaseFactSchema).readonly(),
@@ -64,7 +64,7 @@ const buildHappyExampleInput = (): {
64
64
  id: 'survey.brief',
65
65
  });
66
66
 
67
- const projectActual = (result: Result<unknown, Error>): ActualOutcome => {
67
+ const deriveActualOutcome = (result: Result<unknown, Error>): ActualOutcome => {
68
68
  if (result.isOk()) {
69
69
  return { outcome: 'ok', value: result.value };
70
70
  }
@@ -361,7 +361,7 @@ const buildComparisonEnvelope = async (
361
361
  const executed = await run(app, trailId, example.input, {
362
362
  ctx: permit === undefined ? {} : { permit },
363
363
  });
364
- const actual = projectActual(executed);
364
+ const actual = deriveActualOutcome(executed);
365
365
 
366
366
  if (mode === 'error') {
367
367
  const expectedName = example.error ?? '';
@@ -53,7 +53,7 @@ import {
53
53
  import { createIsolatedExampleInput } from './topo-support.js';
54
54
  import {
55
55
  briefReportSchema,
56
- deriveShippedSurfaceProjectionInventory,
56
+ deriveShippedSurfaceInventory,
57
57
  } from './topo-reports.js';
58
58
  import type { SurfaceLayerNames } from './topo-reports.js';
59
59
 
@@ -61,7 +61,7 @@ export {
61
61
  briefReportSchema,
62
62
  deriveBriefReport,
63
63
  deriveResourceDetail,
64
- deriveShippedSurfaceProjectionInventory,
64
+ deriveShippedSurfaceInventory,
65
65
  deriveSignalDetail,
66
66
  deriveSurveyList,
67
67
  deriveTrailDetail,
@@ -69,7 +69,7 @@ export {
69
69
  export type {
70
70
  BriefReport,
71
71
  ShippedSurfaceInventoryReport,
72
- ShippedSurfaceProjection,
72
+ ShippedSurfaceDerived,
73
73
  SignalDetailReport,
74
74
  SurfaceLayerNames,
75
75
  SurveyListReport,
@@ -562,7 +562,7 @@ const buildSurveySignalDetail = (
562
562
  };
563
563
 
564
564
  const buildSurveySurfaceInventory = (app: Topo): Result<object, Error> =>
565
- Result.ok(deriveShippedSurfaceProjectionInventory(app));
565
+ Result.ok(deriveShippedSurfaceInventory(app));
566
566
 
567
567
  interface SurveyInput {
568
568
  id?: string | undefined;
@@ -827,10 +827,10 @@ export const surveyBriefTrail = trail('survey.brief', {
827
827
  });
828
828
 
829
829
  export const surveySurfacesTrail = trail('survey.surfaces', {
830
- description: 'Inventory shipped surface projections',
830
+ description: 'Inventory shipped surface derived facts',
831
831
  examples: [
832
832
  {
833
- description: 'Show CLI, MCP, and HTTP projections for public trails',
833
+ description: 'Show CLI, MCP, and HTTP derived facts for public trails',
834
834
  input: createIsolatedExampleInput('survey-surfaces'),
835
835
  name: 'Shipped surface inventory',
836
836
  },
@@ -86,27 +86,27 @@ const entityDetailOutput = z.object({
86
86
  surfaces: z.array(z.string()).readonly(),
87
87
  });
88
88
 
89
- const surfaceProjectionBaseOutput = {
89
+ const surfaceDerivedBaseOutput = {
90
90
  derivedName: z.string(),
91
91
  source: z.enum(['authored', 'default-derived']),
92
92
  trailId: z.string(),
93
93
  } as const;
94
94
 
95
- export const surfaceProjectionOutput = z.discriminatedUnion('surface', [
95
+ export const surfaceDerivedOutput = z.discriminatedUnion('surface', [
96
96
  z.object({
97
- ...surfaceProjectionBaseOutput,
97
+ ...surfaceDerivedBaseOutput,
98
98
  commandPath: z.array(z.string()).readonly(),
99
99
  method: z.null(),
100
100
  surface: z.literal('cli'),
101
101
  }),
102
102
  z.object({
103
- ...surfaceProjectionBaseOutput,
103
+ ...surfaceDerivedBaseOutput,
104
104
  method: z.null(),
105
105
  surface: z.literal('mcp'),
106
106
  toolName: z.string(),
107
107
  }),
108
108
  z.object({
109
- ...surfaceProjectionBaseOutput,
109
+ ...surfaceDerivedBaseOutput,
110
110
  method: z.string(),
111
111
  path: z.string(),
112
112
  surface: z.literal('http'),
@@ -115,6 +115,7 @@ export const surfaceProjectionOutput = z.discriminatedUnion('surface', [
115
115
 
116
116
  export const shippedSurfaceInventoryOutput = z.object({
117
117
  count: z.number(),
118
+ derivedSurfaces: z.array(surfaceDerivedOutput).readonly(),
118
119
  excludedSurfaces: z
119
120
  .array(
120
121
  z.object({
@@ -124,13 +125,12 @@ export const shippedSurfaceInventoryOutput = z.object({
124
125
  })
125
126
  )
126
127
  .readonly(),
127
- projections: z.array(surfaceProjectionOutput).readonly(),
128
128
  shippedSurfaces: z.array(z.enum(['cli', 'mcp', 'http'])).readonly(),
129
129
  trails: z
130
130
  .array(
131
131
  z.object({
132
+ derivedSurfaces: z.array(surfaceDerivedOutput).readonly(),
132
133
  explicitSurfaces: z.array(z.string()).readonly(),
133
- projections: z.array(surfaceProjectionOutput).readonly(),
134
134
  trailId: z.string(),
135
135
  })
136
136
  )
@@ -201,6 +201,7 @@ export const trailDetailOutput = z.object({
201
201
  trail: z.array(z.string()).readonly(),
202
202
  }),
203
203
  composes: z.array(z.string()).readonly(),
204
+ derivedSurfaces: z.array(surfaceDerivedOutput).readonly(),
204
205
  description: z.string().nullable(),
205
206
  detours: z
206
207
  .array(
@@ -228,7 +229,6 @@ export const trailDetailOutput = z.object({
228
229
  resources: z.array(z.string()).readonly(),
229
230
  safety: z.string(),
230
231
  supports: z.array(z.number()).readonly(),
231
- surfaceProjections: z.array(surfaceProjectionOutput).readonly(),
232
232
  surfaces: z.array(z.string()).readonly(),
233
233
  version: z.number().nullable(),
234
234
  versions: z.record(z.string(), trailVersionEntryOutput),
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DETOUR_MAX_ATTEMPTS_CAP,
3
- deriveTrailCliCommandProjection,
3
+ deriveTrailCliCommandRendering,
4
4
  filterSurfaceTrails,
5
5
  isArchivedTrailVersionEntry,
6
6
  zodToJsonSchema,
@@ -78,21 +78,21 @@ export type SurfaceLayerNames = Readonly<
78
78
 
79
79
  export type ShippedSurfaceKey = 'cli' | 'mcp' | 'http';
80
80
 
81
- export type SurfaceProjectionSource = 'authored' | 'default-derived';
81
+ export type SurfaceDerivedSource = 'authored' | 'default-derived';
82
82
 
83
- export type ShippedSurfaceProjection =
83
+ export type ShippedSurfaceDerived =
84
84
  | {
85
85
  readonly commandPath: readonly string[];
86
86
  readonly derivedName: string;
87
87
  readonly method: null;
88
- readonly source: SurfaceProjectionSource;
88
+ readonly source: SurfaceDerivedSource;
89
89
  readonly surface: 'cli';
90
90
  readonly trailId: string;
91
91
  }
92
92
  | {
93
93
  readonly derivedName: string;
94
94
  readonly method: null;
95
- readonly source: SurfaceProjectionSource;
95
+ readonly source: SurfaceDerivedSource;
96
96
  readonly surface: 'mcp';
97
97
  readonly toolName: string;
98
98
  readonly trailId: string;
@@ -101,7 +101,7 @@ export type ShippedSurfaceProjection =
101
101
  readonly derivedName: string;
102
102
  readonly method: HttpMethod;
103
103
  readonly path: string;
104
- readonly source: SurfaceProjectionSource;
104
+ readonly source: SurfaceDerivedSource;
105
105
  readonly surface: 'http';
106
106
  readonly trailId: string;
107
107
  };
@@ -113,11 +113,11 @@ export interface ShippedSurfaceInventoryReport {
113
113
  readonly status: 'planned';
114
114
  readonly surface: 'websocket';
115
115
  }[];
116
- readonly projections: readonly ShippedSurfaceProjection[];
116
+ readonly derivedSurfaces: readonly ShippedSurfaceDerived[];
117
117
  readonly shippedSurfaces: readonly ShippedSurfaceKey[];
118
118
  readonly trails: readonly {
119
119
  readonly explicitSurfaces: readonly string[];
120
- readonly projections: readonly ShippedSurfaceProjection[];
120
+ readonly derivedSurfaces: readonly ShippedSurfaceDerived[];
121
121
  readonly trailId: string;
122
122
  }[];
123
123
  }
@@ -212,7 +212,7 @@ export interface TrailDetailReport {
212
212
  readonly pattern: string | null;
213
213
  readonly safety: string;
214
214
  readonly resources: readonly string[];
215
- readonly surfaceProjections: readonly ShippedSurfaceProjection[];
215
+ readonly derivedSurfaces: readonly ShippedSurfaceDerived[];
216
216
  readonly surfaces: readonly string[];
217
217
  readonly supports: readonly number[];
218
218
  readonly version: number | null;
@@ -519,10 +519,10 @@ const PLANNED_SURFACE_EXCLUSIONS = [
519
519
  const surfaceOrder = (surface: ShippedSurfaceKey): number =>
520
520
  SHIPPED_SURFACES.indexOf(surface);
521
521
 
522
- const sortSurfaceProjections = (
523
- projections: readonly ShippedSurfaceProjection[]
524
- ): readonly ShippedSurfaceProjection[] =>
525
- projections.toSorted(
522
+ const sortSurfaceDerived = (
523
+ derivedSurfaces: readonly ShippedSurfaceDerived[]
524
+ ): readonly ShippedSurfaceDerived[] =>
525
+ derivedSurfaces.toSorted(
526
526
  (a, b) =>
527
527
  a.trailId.localeCompare(b.trailId) ||
528
528
  surfaceOrder(a.surface) - surfaceOrder(b.surface)
@@ -532,10 +532,10 @@ const explicitSurfacesForEntry = (
532
532
  entry: TopoGraphEntry | undefined
533
533
  ): readonly string[] => entry?.surfaces ?? [];
534
534
 
535
- const projectionSource = (
535
+ const derivedSource = (
536
536
  entry: TopoGraphEntry | undefined,
537
537
  surface: ShippedSurfaceKey
538
- ): SurfaceProjectionSource =>
538
+ ): SurfaceDerivedSource =>
539
539
  explicitSurfacesForEntry(entry).includes(surface)
540
540
  ? 'authored'
541
541
  : 'default-derived';
@@ -547,11 +547,11 @@ const isSurfaceEligibleTrail = (app: Topo, trail: AnyTrail): boolean =>
547
547
  filterSurfaceTrails([trail]).length > 0 &&
548
548
  app.trails.get(trail.id) !== undefined;
549
549
 
550
- export const deriveShippedSurfaceProjectionsForTrail = (
550
+ export const deriveShippedSurfaceFactsForTrail = (
551
551
  app: Topo,
552
552
  trail: AnyTrail,
553
553
  topoGraph?: TopoGraph | undefined
554
- ): readonly ShippedSurfaceProjection[] => {
554
+ ): readonly ShippedSurfaceDerived[] => {
555
555
  if (!isSurfaceEligibleTrail(app, trail)) {
556
556
  return [];
557
557
  }
@@ -562,24 +562,24 @@ export const deriveShippedSurfaceProjectionsForTrail = (
562
562
  'trail'
563
563
  );
564
564
  const commandPath =
565
- entry?.cli?.path ?? deriveTrailCliCommandProjection(trail).path;
565
+ entry?.cli?.path ?? deriveTrailCliCommandRendering(trail).path;
566
566
  const httpMethod = deriveHttpMethod(trail.intent);
567
567
  const httpPath = deriveHttpPath(trail.id);
568
568
  const mcpToolName = deriveToolName(app.name, trail.id);
569
569
 
570
- return sortSurfaceProjections([
570
+ return sortSurfaceDerived([
571
571
  {
572
572
  commandPath,
573
573
  derivedName: commandPath.join(' '),
574
574
  method: null,
575
- source: projectionSource(entry, 'cli'),
575
+ source: derivedSource(entry, 'cli'),
576
576
  surface: 'cli',
577
577
  trailId: trail.id,
578
578
  },
579
579
  {
580
580
  derivedName: mcpToolName,
581
581
  method: null,
582
- source: projectionSource(entry, 'mcp'),
582
+ source: derivedSource(entry, 'mcp'),
583
583
  surface: 'mcp',
584
584
  toolName: mcpToolName,
585
585
  trailId: trail.id,
@@ -588,16 +588,16 @@ export const deriveShippedSurfaceProjectionsForTrail = (
588
588
  derivedName: httpPath,
589
589
  method: httpMethod,
590
590
  path: httpPath,
591
- source: projectionSource(entry, 'http'),
591
+ source: derivedSource(entry, 'http'),
592
592
  surface: 'http',
593
593
  trailId: trail.id,
594
594
  },
595
595
  ]);
596
596
  };
597
597
 
598
- const deriveFallbackSurfaceProjections = (
598
+ const deriveFallbackSurfaceFacts = (
599
599
  entry: TopoGraphEntry | undefined
600
- ): readonly ShippedSurfaceProjection[] => {
600
+ ): readonly ShippedSurfaceDerived[] => {
601
601
  if (entry?.cli === undefined) {
602
602
  return [];
603
603
  }
@@ -607,58 +607,58 @@ const deriveFallbackSurfaceProjections = (
607
607
  commandPath: entry.cli.path,
608
608
  derivedName: entry.cli.path.join(' '),
609
609
  method: null,
610
- source: projectionSource(entry, 'cli'),
610
+ source: derivedSource(entry, 'cli'),
611
611
  surface: 'cli',
612
612
  trailId: entry.id,
613
613
  },
614
614
  ];
615
615
  };
616
616
 
617
- export const deriveShippedSurfaceProjectionInventory = (
617
+ export const deriveShippedSurfaceInventory = (
618
618
  app: Topo
619
619
  ): ShippedSurfaceInventoryReport => {
620
620
  const topoGraph = deriveTopoGraph(app);
621
621
  const trails = filterSurfaceTrails(app.list()).map((trail) => {
622
622
  const entry = findTopoEntry(topoGraph, trail.id, 'trail');
623
- const projections = deriveShippedSurfaceProjectionsForTrail(
623
+ const derivedSurfaces = deriveShippedSurfaceFactsForTrail(
624
624
  app,
625
625
  trail,
626
626
  topoGraph
627
627
  );
628
628
 
629
629
  return {
630
+ derivedSurfaces,
630
631
  explicitSurfaces: explicitSurfacesForEntry(entry),
631
- projections,
632
632
  trailId: trail.id,
633
633
  };
634
634
  });
635
- const projections = sortSurfaceProjections(
636
- trails.flatMap((trail) => trail.projections)
635
+ const derivedSurfaces = sortSurfaceDerived(
636
+ trails.flatMap((trail) => trail.derivedSurfaces)
637
637
  );
638
638
 
639
639
  return {
640
640
  count: trails.length,
641
+ derivedSurfaces,
641
642
  excludedSurfaces: PLANNED_SURFACE_EXCLUSIONS,
642
- projections,
643
643
  shippedSurfaces: SHIPPED_SURFACES,
644
644
  trails: trails.toSorted((a, b) => a.trailId.localeCompare(b.trailId)),
645
645
  };
646
646
  };
647
647
 
648
- const deriveResolvedSurfaceProjections = (
648
+ const deriveResolvedSurfaceFacts = (
649
649
  app: Topo | undefined,
650
650
  trailId: string,
651
651
  topoEntry: TopoGraphEntry | undefined,
652
652
  topoGraph: TopoGraph | undefined
653
- ): readonly ShippedSurfaceProjection[] => {
653
+ ): readonly ShippedSurfaceDerived[] => {
654
654
  if (app === undefined) {
655
- return deriveFallbackSurfaceProjections(topoEntry);
655
+ return deriveFallbackSurfaceFacts(topoEntry);
656
656
  }
657
657
 
658
658
  const trail = app.trails.get(trailId);
659
659
  return trail === undefined
660
- ? deriveFallbackSurfaceProjections(topoEntry)
661
- : deriveShippedSurfaceProjectionsForTrail(app, trail, topoGraph);
660
+ ? deriveFallbackSurfaceFacts(topoEntry)
661
+ : deriveShippedSurfaceFactsForTrail(app, trail, topoGraph);
662
662
  };
663
663
 
664
664
  const deriveResolvedTrailVersionDetail = (
@@ -686,7 +686,7 @@ const deriveResolvedTrailGraphDetail = (
686
686
  | 'input'
687
687
  | 'layers'
688
688
  | 'output'
689
- | 'surfaceProjections'
689
+ | 'derivedSurfaces'
690
690
  | 'surfaces'
691
691
  | 'supports'
692
692
  | 'version'
@@ -715,6 +715,12 @@ const deriveResolvedTrailGraphDetail = (
715
715
  fallbackActivationEdges
716
716
  ),
717
717
  cli: topoEntry?.cli ?? null,
718
+ derivedSurfaces: deriveResolvedSurfaceFacts(
719
+ app,
720
+ trailId,
721
+ topoEntry,
722
+ topoGraph
723
+ ),
718
724
  entities,
719
725
  entityDetails,
720
726
  fieldOverrides: topoEntry?.fieldOverrides ?? [],
@@ -722,12 +728,6 @@ const deriveResolvedTrailGraphDetail = (
722
728
  input: topoEntry?.input ?? null,
723
729
  layers: topoEntry?.layers ?? [],
724
730
  output: topoEntry?.output ?? null,
725
- surfaceProjections: deriveResolvedSurfaceProjections(
726
- app,
727
- trailId,
728
- topoEntry,
729
- topoGraph
730
- ),
731
731
  surfaces: topoEntry?.surfaces ?? [],
732
732
  ...deriveResolvedTrailVersionDetail(topoEntry),
733
733
  };
@@ -782,6 +782,7 @@ export const deriveTrailDetail = (
782
782
  trail: trailLayerNames,
783
783
  },
784
784
  composes: item.composes.toSorted(),
785
+ derivedSurfaces: graphDetail.derivedSurfaces,
785
786
  description: item.description ?? null,
786
787
  detours: formatTrailDetours(item),
787
788
  entities: graphDetail.entities,
@@ -801,7 +802,6 @@ export const deriveTrailDetail = (
801
802
  resources: item.resources.map((resource) => resource.id).toSorted(),
802
803
  safety,
803
804
  supports: graphDetail.supports,
804
- surfaceProjections: graphDetail.surfaceProjections,
805
805
  surfaces: graphDetail.surfaces,
806
806
  version: graphDetail.version,
807
807
  versions: graphDetail.versions,
@@ -140,12 +140,10 @@ export const deriveCurrentTopoExport = (
140
140
  const db = new Database(':memory:');
141
141
 
142
142
  try {
143
- const projected = persistAndReadStoredExport(app, db, rootDir, {
143
+ const derived = persistAndReadStoredExport(app, db, rootDir, {
144
144
  overlays: options?.overlays,
145
145
  });
146
- return projected.isErr()
147
- ? projected
148
- : Result.ok(projected.value.storedExport);
146
+ return derived.isErr() ? derived : Result.ok(derived.value.storedExport);
149
147
  } finally {
150
148
  db.close();
151
149
  }
@@ -104,7 +104,7 @@ const wardenGuideFields = {
104
104
  >;
105
105
 
106
106
  export const wardenGuideTrail = trail('warden.guide', {
107
- description: 'Project Warden rule guidance as markdown or JSON',
107
+ description: 'Render Warden rule guidance as markdown or JSON',
108
108
  examples: [
109
109
  {
110
110
  input: { guideFormat: 'markdown' },