@leitwerk-dev/domain 0.3.0 → 0.4.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.
@@ -23,7 +23,7 @@ export interface SerializedProcessGraph {
23
23
  /** @internal */
24
24
  turnTransitions: Record<TurnId, ProcessTurnTransition[]>;
25
25
  }
26
- /** Whether a flow node sits on the declared happy path (`spine`) or hangs off it (`branch`). @internal */
26
+ /** Whether a flow node sits on the shortest successful path or a side branch. @internal */
27
27
  export type ProcessFlowNodeRole = "spine" | "branch";
28
28
  /**
29
29
  * Classification of a flow edge relative to the spine:
@@ -34,6 +34,15 @@ export type ProcessFlowNodeRole = "spine" | "branch";
34
34
  */
35
35
  /** @internal */
36
36
  export type ProcessFlowEdgeKind = "forward" | "loopback" | "branch" | "terminal";
37
+ /** A statically declared LLM tool, without executable code or runtime credentials. @internal */
38
+ export interface ProcessFlowTool {
39
+ /** @internal */
40
+ name: string;
41
+ /** @internal */
42
+ category: "workspace" | "integration" | "question" | "outcome";
43
+ /** Declared description when available; integration registrations are resolved separately. @internal */
44
+ description: string | null;
45
+ }
37
46
  /** @internal */
38
47
  export interface ProcessFlowNode {
39
48
  /** @internal */
@@ -50,6 +59,16 @@ export interface ProcessFlowNode {
50
59
  anchorTurnId: TurnId | null;
51
60
  /** True when this turn is a launch entry point. @internal */
52
61
  isEntry: boolean;
62
+ /** One logical turn applied to frozen items, followed by internal collection. @internal */
63
+ repetition?: "sequential";
64
+ /** Static declarations only; absent on non-LLM turns and older projections. @internal */
65
+ tools?: ProcessFlowTool[];
66
+ /** Additional integration tool names are resolved from process data at turn start. @internal */
67
+ hasDynamicTools?: boolean;
68
+ /** Named product declarations, not execution-time values. @internal */
69
+ inputProducts?: string[];
70
+ /** Named products this turn can publish. @internal */
71
+ outputProducts?: string[];
53
72
  }
54
73
  /** @internal */
55
74
  export interface ProcessFlowEdge {
@@ -63,6 +82,11 @@ export interface ProcessFlowEdge {
63
82
  kind: ProcessFlowEdgeKind;
64
83
  /** Optional human-facing edge label derived from outcome/trigger metadata. @internal */
65
84
  label: string | null;
85
+ /** Declared branch condition; inspecting the graph never evaluates its chooser. @internal */
86
+ condition?: {
87
+ /** @internal */ label: string;
88
+ /** @internal */ description?: string;
89
+ };
66
90
  }
67
91
  /** @internal */
68
92
  export interface ProcessFlowEndState {
@@ -76,8 +100,9 @@ export interface ProcessFlowEndState {
76
100
  synthetic: boolean;
77
101
  }
78
102
  /**
79
- * Spine-first projection of a process graph for operator-facing flow diagrams.
80
- * The `spine` is the happy path; everything else hangs off it as branches and loops.
103
+ * Complete definition projection for operator-facing flow diagrams.
104
+ * The `spine` is the shortest path from the primary entry to completion.
105
+ * Operator decisions remain explicit; collection stays inside a mapped turn.
81
106
  */
82
107
  /** @internal */
83
108
  export interface ProcessFlowView {
@@ -1 +1 @@
1
- {"version":3,"file":"process-definitions.d.ts","sourceRoot":"","sources":["../src/process-definitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEzF,cAAc;AACd,MAAM,MAAM,kCAAkC,GAAG,OAAO,CACvD,sBAAsB,EACtB,WAAW,GAAG,SAAS,CACvB,CAAC;AAEF,gBAAgB;AAChB,MAAM,WAAW,qBAAqB;IACrC,gBAAgB;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB;IAChB,eAAe,CAAC,EAAE,kCAAkC,CAAC;IACrD,gBAAgB;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,uFAAuF;AACvF,MAAM,WAAW,sBAAsB;IACtC,gBAAgB;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,gBAAgB;IAChB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB;IAChB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,gBAA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YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,gBAAgB;IAChB,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,gBAAgB;IAChB,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,gBAAgB;IAChB,SAAS,EAAE,mBAAmB,EAAE,CAAC;CACjC"}
1
+ {"version":3,"file":"process-definitions.d.ts","sourceRoot":"","sources":["../src/process-definitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEzF,cAAc;AACd,MAAM,MAAM,kCAAkC,GAAG,OAAO,CACvD,sBAAsB,EACtB,WAAW,GAAG,SAAS,CACvB,CAAC;AAEF,gBAAgB;AAChB,MAAM,WAAW,qBAAqB;IACrC,gBAAgB;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB;IAChB,eAAe,CAAC,EAAE,kCAAkC,CAAC;IACrD,gBAAgB;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,uFAAuF;AACvF,MAAM,WAAW,sBAAsB;IACtC,gBAAgB;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,gBAAgB;IAChB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB;IAChB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,gBAAgB;IAChB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,EAAE,CAAC,CAAC;CACzD;AAED,2FAA2F;AAC3F,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErD;;;;;;GAMG;AACH,gBAAgB;AAChB,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEjF,gGAAgG;A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AgB,CAAC,KAAK,EAAE,MAAM,CAAC;QAC/B,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;KACtC,CAAC;CACF;AAED,gBAAgB;AAChB,MAAM,WAAW,mBAAmB;IACnC,gBAAgB;IAChB,eAAe,EAAE,kCAAkC,CAAC;IACpD;;;OAGG;IACH,gBAAgB;IAChB,SAAS,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,gBAAgB;AAChB,MAAM,WAAW,eAAe;IAC/B,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB;IAChB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,gBAAgB;IAChB,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,gBAAgB;IAChB,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,gBAAgB;IAChB,SAAS,EAAE,mBAAmB,EAAE,CAAC;CACjC"}
@@ -0,0 +1,4 @@
1
+ import type { TurnId } from "./domain-model.js";
2
+ /** Breadth-first path in declaration order; null marks success. Returns [entry] without success. @internal */
3
+ export declare function shortestSuccessfulTurnPath(entry: TurnId, outgoing: (id: TurnId) => Iterable<TurnId | null>): TurnId[];
4
+ //# sourceMappingURL=process-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-path.d.ts","sourceRoot":"","sources":["../src/process-path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,8GAA8G;AAC9G,wBAAgB,0BAA0B,CACzC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,GAC/C,MAAM,EAAE,CAkBV"}
@@ -0,0 +1,87 @@
1
+ import type { Actor } from "./domain-model.js";
2
+ /** One stable subject per named scope type. @public */
3
+ export type SettingsContext = Readonly<Record<string, string>>;
4
+ /** @public */
5
+ export interface SettingsSubject {
6
+ /** @public */
7
+ id: string;
8
+ /** @public */
9
+ scopeType: string;
10
+ /** @public */
11
+ identity: string;
12
+ /** @public */
13
+ label: string;
14
+ /** Lower scopes supplied by the owning integration, never matched by expression. @public */
15
+ context: SettingsContext;
16
+ /** @public */
17
+ schemaVersion: number;
18
+ /** @public */
19
+ revision: number;
20
+ /** @public */
21
+ createdAt: string;
22
+ /** @public */
23
+ updatedAt: string;
24
+ /** Discovery is attributed to the server system actor. @public */
25
+ actor: Actor;
26
+ }
27
+ /** A reset retains its revision to prevent delete/recreate races. @internal */
28
+ export interface SettingsOverride {
29
+ /** @internal */
30
+ subjectId: string;
31
+ /** @internal */
32
+ key: string;
33
+ /** @internal */
34
+ value: unknown;
35
+ /** @internal */
36
+ mode: "append" | "replace";
37
+ /** @internal */
38
+ reset: boolean;
39
+ /** @internal */
40
+ schemaVersion: number;
41
+ /** @internal */
42
+ revision: number;
43
+ /** @internal */
44
+ createdAt: string;
45
+ /** @internal */
46
+ updatedAt: string;
47
+ /** @internal */
48
+ actor: Actor;
49
+ }
50
+ /** @public */
51
+ export interface SettingsSource {
52
+ /** @public */
53
+ subjectId: string | null;
54
+ /** @public */
55
+ scopeType: string;
56
+ /** @public */
57
+ label: string;
58
+ /** @public */
59
+ revision: number;
60
+ /** @public */
61
+ schemaVersion: number;
62
+ /** @public */
63
+ mode: "append" | "replace";
64
+ }
65
+ /** @public */
66
+ export interface ResolvedSetting<T = unknown> {
67
+ /** @public */
68
+ key: string;
69
+ /** @public */
70
+ value: T;
71
+ /** @public */
72
+ sources: SettingsSource[];
73
+ }
74
+ /** Immutable, non-secret settings consumed by a prepared turn. @public */
75
+ export interface ScopedSettingsSnapshot {
76
+ /** @public */
77
+ version: 1;
78
+ /** @public */
79
+ purpose: string;
80
+ /** @public */
81
+ context: SettingsContext;
82
+ /** @public */
83
+ values: ResolvedSetting[];
84
+ /** @public */
85
+ explanations: string[];
86
+ }
87
+ //# sourceMappingURL=scoped-settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scoped-settings.d.ts","sourceRoot":"","sources":["../src/scoped-settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,uDAAuD;AACvD,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE/D,cAAc;AACd,MAAM,WAAW,eAAe;IAC/B,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IACX,cAAc;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc;IACd,KAAK,EAAE,MAAM,CAAC;IACd,4FAA4F;IAC5F,OAAO,EAAE,eAAe,CAAC;IACzB,cAAc;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,KAAK,EAAE,KAAK,CAAC;CACb;AAED,+EAA+E;AAC/E,MAAM,WAAW,gBAAgB;IAChC,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,gBAAgB;IAChB,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC3B,gBAAgB;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,gBAAgB;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB;IAChB,KAAK,EAAE,KAAK,CAAC;CACb;AAED,cAAc;AACd,MAAM,WAAW,cAAc;IAC9B,cAAc;IACd,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,cAAc;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc;IACd,KAAK,EAAE,MAAM,CAAC;IACd,cAAc;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc;IACd,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC3B;AAED,cAAc;AACd,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO;IAC3C,cAAc;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc;IACd,KAAK,EAAE,CAAC,CAAC;IACT,cAAc;IACd,OAAO,EAAE,cAAc,EAAE,CAAC;CAC1B;AAED,0EAA0E;AAC1E,MAAM,WAAW,sBAAsB;IACtC,cAAc;IACd,OAAO,EAAE,CAAC,CAAC;IACX,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc;IACd,OAAO,EAAE,eAAe,CAAC;IACzB,cAAc;IACd,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,cAAc;IACd,YAAY,EAAE,MAAM,EAAE,CAAC;CACvB"}
@@ -2,7 +2,7 @@ import { trimToNull } from "./string-normalize.js";
2
2
  /** @internal */
3
3
  export declare const DEFAULT_CONTINUE_PROMPT = "continue";
4
4
  /** @internal */
5
- export declare const FAILED_TURN_RECOVERY_CODES: readonly ["generic_continue", "missing_outcome_tool", "missing_markdown_result", "missing_required_tool_calls"];
5
+ export declare const FAILED_TURN_RECOVERY_CODES: readonly ["generic_continue", "outcome_rejected", "missing_outcome_tool", "missing_markdown_result", "missing_required_tool_calls"];
6
6
  /** @internal */
7
7
  export type FailedTurnRecoveryCode = (typeof FAILED_TURN_RECOVERY_CODES)[number];
8
8
  /** @internal */
@@ -1 +1 @@
1
- {"version":3,"file":"turn-recovery.d.ts","source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AmB,CAAC;AAI7D,gBAAgB;AAChB,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,sBAAsB,CAEvF;AAOD,OAAO,EAAE,UAAU,IAAI,uBAAuB,EAAE,CAAC;AAEjD,gBAAgB;AAChB,wBAAgB,sCAAsC,CACrD,SAAS,GAAE,2BAAgC,GACzC,yBAAyB,CAO3B;AAED,gBAAgB;AAChB,wBAAgB,+CAA+C,CAAC,KAAK,EAAE;IACtE,gBAAgB;IAChB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,gBAAgB;IAChB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,GAAG,yBAAyB,GAAG,IAAI,CAQnC;AAED,gBAAgB;AAChB,wBAAgB,+BAA+B,CAC9C,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,2BAAgC;IAGxC,gBAAgB;;QAlEjB,gBAAgB;kBACN,UAAU;QACpB,gBAAgB;iCACS,MAAM;QAC/B,gBAAgB;qBACH,sBAAsB;QACnC,gBAAgB;2BACG,MAAM,EAAE;QA6DzB,gBAAgB;;;EAKlB;AAED,gBAAgB;AAChB,wBAAgB,6BAA6B,CAC5C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,EACpD,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,GAClC,yBAAyB,GAAG,IAAI,CA6BlC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leitwerk-dev/domain",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/leitwerk-dev/leitwerk.git",
@@ -0,0 +1,19 @@
1
+ /** Dependency-first traversal; callers resolve missing and optional dependencies. @internal */
2
+ export function orderDependencies(
3
+ roots: Iterable<string>,
4
+ dependencies: (id: string) => Iterable<string>,
5
+ cycleMessage: (id: string) => string,
6
+ ): string[] {
7
+ const visiting = new Set<string>();
8
+ const ordered = new Set<string>();
9
+ function visit(id: string): void {
10
+ if (ordered.has(id)) return;
11
+ if (visiting.has(id)) throw new Error(cycleMessage(id));
12
+ visiting.add(id);
13
+ for (const dependency of dependencies(id)) visit(dependency);
14
+ visiting.delete(id);
15
+ ordered.add(id);
16
+ }
17
+ for (const id of roots) visit(id);
18
+ return [...ordered];
19
+ }
@@ -1,4 +1,5 @@
1
1
  import type { RepoLocatorKind } from "./repo-locator.js";
2
+ import type { ScopedSettingsSnapshot } from "./scoped-settings.js";
2
3
  import type { ProcessSemanticEntryRefKey } from "./semantic-entry-refs.js";
3
4
  import { trimToNull } from "./string-normalize.js";
4
5
  import type { FailedTurnRecoveryContext } from "./turn-recovery.js";
@@ -451,6 +452,7 @@ export type ProcessSelectedTurnModelSource =
451
452
  | "instance_turn_config"
452
453
  | "process_config_turn"
453
454
  | "instance_default"
455
+ | "scoped_purpose_default"
454
456
  | "process_config_default"
455
457
  | "catalog_default"
456
458
  | "legacy_persisted";
@@ -514,6 +516,10 @@ export type CurrentExecutionRef = {
514
516
  /** Immutable non-secret inputs resolved for a worker-owned turn start. @internal */
515
517
  export type ResolvedTurnStart =
516
518
  | {
519
+ /** Resolved non-secret outcome schemas and publication metadata. @internal */
520
+ outcomeContract?: JsonObject;
521
+ /** @internal */
522
+ scopedSettings?: ScopedSettingsSnapshot;
517
523
  /** @internal */
518
524
  kind: "llm";
519
525
  /** @internal */
@@ -647,12 +653,76 @@ export interface TurnStartRecord {
647
653
  continuation: TurnStartContinuation | null;
648
654
  /** @internal */
649
655
  state: TurnStartRecordState;
656
+ /** Mapped-turn item this start executes; null for ordinary turns. @internal */
657
+ iteration?: MappedTurnItemRef | null;
658
+ /** @internal */
659
+ createdAt: string;
660
+ /** @internal */
661
+ updatedAt: string;
662
+ }
663
+
664
+ /** Identity of one frozen item in a mapped LLM run. @internal */
665
+ export interface MappedTurnItemRef {
666
+ /** @internal */
667
+ runId: string;
668
+ /** @internal */
669
+ itemKey: string;
670
+ /** Zero-based position in the frozen order. @internal */
671
+ itemIndex: number;
672
+ }
673
+
674
+ /** @internal */
675
+ export type MappedRunStatus = "active" | "completed" | "aborted";
676
+
677
+ /** Durable bookkeeping for one sequential pass of a mapped LLM turn. @internal */
678
+ export interface MappedRun {
679
+ /** @internal */
680
+ id: string;
681
+ /** @internal */
682
+ instanceId: string;
683
+ /** @internal */
684
+ turnId: TurnId;
685
+ /** @internal */
686
+ status: MappedRunStatus;
687
+ /** @internal */
688
+ itemCount: number;
689
+ /** Index of the item currently executing, or itemCount when all results exist. @internal */
690
+ nextIndex: number;
650
691
  /** @internal */
651
692
  createdAt: string;
652
693
  /** @internal */
653
694
  updatedAt: string;
654
695
  }
655
696
 
697
+ /** @internal */
698
+ export type MappedItemStatus = "pending" | "completed";
699
+
700
+ /** One frozen item of a mapped run and its validated result. @internal */
701
+ export interface MappedItem {
702
+ /** @internal */
703
+ runId: string;
704
+ /** @internal */
705
+ instanceId: string;
706
+ /** @internal */
707
+ itemIndex: number;
708
+ /** @internal */
709
+ itemKey: string;
710
+ /** @internal */
711
+ label: string;
712
+ /** Codec-serialized item value. @internal */
713
+ itemJson: string;
714
+ /** @internal */
715
+ status: MappedItemStatus;
716
+ /** @internal */
717
+ outcome: string | null;
718
+ /** Codec-serialized result, set once when the item completes. @internal */
719
+ resultJson: string | null;
720
+ /** Turn record whose outcome produced the result. @internal */
721
+ turnRecordId: string | null;
722
+ /** @internal */
723
+ completedAt: string | null;
724
+ }
725
+
656
726
  /** Tree positioning selected during bootstrap, before a turn is accepted. @internal */
657
727
  export interface PreparedTurnStart {
658
728
  /** @internal */
@@ -718,6 +788,7 @@ export const PROCESS_SELECTED_TURN_MODEL_SOURCES = [
718
788
  "process_config_turn",
719
789
  "instance_default",
720
790
  "process_config_default",
791
+ "scoped_purpose_default",
721
792
  "catalog_default",
722
793
  "legacy_persisted",
723
794
  ] as const satisfies readonly ProcessSelectedTurnModelSource[];
@@ -1033,7 +1104,7 @@ export interface TurnProgressReport {
1033
1104
  title: string;
1034
1105
  /** Attempt-specific progress or waiting explanation; not an operation receipt. @public */
1035
1106
  summary?: string;
1036
- /** @public */
1107
+ /** Optional checklist; may be empty when summary supplies the activity text. @public */
1037
1108
  steps: TurnProgressStep[];
1038
1109
  /** @public */
1039
1110
  links?: TurnProgressLink[];
@@ -1081,6 +1152,8 @@ export interface ProcessTurnRecord {
1081
1152
  modelProfileId: string | null;
1082
1153
  /** @internal */
1083
1154
  modelSelectionProvenance?: ModelSelectionProvenance | null;
1155
+ /** Mapped-turn item this record executed; retries keep the same item. @internal */
1156
+ iteration?: MappedTurnItemRef | null;
1084
1157
  /** @internal */
1085
1158
  turnResultMarkdown: string | null;
1086
1159
  /** @public */
@@ -0,0 +1,182 @@
1
+ import type { PreparedTurnStart } from "./domain-model.js";
2
+
3
+ /** Completeness of one historical fact, independent of request/loading state. @internal */
4
+ export type InspectionEvidence<T> =
5
+ | {
6
+ /** @internal */
7
+ state: "recorded" | "redacted";
8
+ /** @internal */
9
+ value: T;
10
+ }
11
+ | {
12
+ /** @internal */
13
+ state: "not_recorded" | "unavailable" | "not_applicable";
14
+ /** @internal */
15
+ reason: string;
16
+ };
17
+
18
+ /** Immutable version supplied to a worker, not a declaration of possible consumption. @internal */
19
+ export interface InspectionProduct {
20
+ /** @internal */
21
+ name: string;
22
+ /** @internal */
23
+ producerTurnRecordId: string;
24
+ /** @internal */
25
+ entryId: string;
26
+ /** @internal */
27
+ content: InspectionEvidence<string>;
28
+ }
29
+
30
+ /** Model-facing content only. Renderer details and provider options are deliberately absent. @internal */
31
+ export interface InspectionMessage {
32
+ /** Exact session identity when the conversion is unambiguous. @internal */
33
+ entryId: string | null;
34
+ /** @internal */
35
+ role: string;
36
+ /** @internal */
37
+ toolCallId?: string;
38
+ /** @internal */
39
+ content: InspectionEvidence<unknown>;
40
+ }
41
+
42
+ /** Captured at the Pi stream function after context conversion and tool assembly. @internal */
43
+ export interface InspectionModelInput {
44
+ /** @internal */
45
+ kind: "model_input";
46
+ /** @internal */
47
+ boundaryEntryId: string | null;
48
+ /** @internal */
49
+ model: {
50
+ /** @internal */
51
+ provider: string;
52
+ /** @internal */
53
+ id: string;
54
+ /** @internal */
55
+ thinkingLevel: string | null;
56
+ };
57
+ /** @internal */
58
+ systemPrompt: InspectionEvidence<string>;
59
+ /** @internal */
60
+ appendedInstructions: InspectionEvidence<string[]>;
61
+ /** @internal */
62
+ contextFiles: InspectionEvidence<
63
+ Array<{
64
+ /** @internal */
65
+ path: string;
66
+ /** @internal */
67
+ content: string;
68
+ }>
69
+ >;
70
+ /** @internal */
71
+ tools: InspectionEvidence<
72
+ Array<{
73
+ /** @internal */
74
+ name: string;
75
+ /** @internal */
76
+ description: string;
77
+ /** @internal */
78
+ parameters: unknown;
79
+ /** @internal */
80
+ strictSchema?: boolean;
81
+ /** @internal */
82
+ schemaEnforcement?: "provider" | "server";
83
+ }>
84
+ >;
85
+ /** Ordered references are retained per call; immutable content is stored once. @internal */
86
+ messages: InspectionMessage[];
87
+ }
88
+
89
+ /** Versioned worker observation, correlated by the server to an accepted execution and lease. @internal */
90
+ export interface ExecutionInspectionCapture {
91
+ /** Idempotency identity for this observation. @internal */
92
+ id: string;
93
+ /** @internal */
94
+ version: 1;
95
+ /** @internal */
96
+ timestamp: string;
97
+ /** @internal */
98
+ fact:
99
+ | InspectionModelInput
100
+ | {
101
+ /** @internal */
102
+ kind: "supplied_context";
103
+ /** @internal */
104
+ origin: PreparedTurnStart | null;
105
+ /** @internal */
106
+ products: InspectionProduct[];
107
+ }
108
+ | {
109
+ /** @internal */
110
+ kind: "product_consumed";
111
+ /** @internal */
112
+ supplyId: string;
113
+ /** @internal */
114
+ name: string;
115
+ }
116
+ | {
117
+ /** @internal */
118
+ kind: "entry_link";
119
+ /** @internal */
120
+ entryId: string;
121
+ /** @internal */
122
+ piTurnId: string;
123
+ /** @internal */
124
+ role: string;
125
+ };
126
+ }
127
+
128
+ /** Compact lineage evidence excludes retained content. @internal */
129
+ export interface InspectionContextObservation {
130
+ /** @internal */
131
+ id: string;
132
+ /** @internal */
133
+ turnRecordId: string;
134
+ /** @internal */
135
+ fact:
136
+ | Exclude<
137
+ ExecutionInspectionCapture["fact"],
138
+ InspectionModelInput | { kind: "supplied_context" }
139
+ >
140
+ | {
141
+ /** @internal */
142
+ kind: "supplied_context";
143
+ /** @internal */
144
+ origin: PreparedTurnStart | null;
145
+ /** @internal */
146
+ products: Omit<InspectionProduct, "content">[];
147
+ };
148
+ }
149
+
150
+ /** Server-owned persisted observation. @internal */
151
+ export interface ExecutionInspectionRecord extends ExecutionInspectionCapture {
152
+ /** @internal */
153
+ sequence: number;
154
+ /** @internal */
155
+ instanceId: string;
156
+ /** @internal */
157
+ turnRecordId: string;
158
+ /** @internal */
159
+ startRecordId: string;
160
+ /** Physical reporter, which can differ from the original accepting lease. @internal */
161
+ workerLeaseId: string;
162
+ }
163
+
164
+ /** Redaction is retained as evidence, not silently presented as a complete capture. @internal */
165
+ export function redactInspectionEvidence<T>(value: T, redact: (text: string) => string): T {
166
+ if (typeof value === "string") return redact(value) as T;
167
+ if (Array.isArray(value)) return value.map((item) => redactInspectionEvidence(item, redact)) as T;
168
+ if (!value || typeof value !== "object") return value;
169
+ const original = value as Record<string, unknown>;
170
+ const safe = Object.fromEntries(
171
+ Object.entries(original).map(([key, item]) => [
172
+ redact(key),
173
+ redactInspectionEvidence(item, redact),
174
+ ]),
175
+ );
176
+ if (
177
+ original.state === "recorded" &&
178
+ JSON.stringify(original.value) !== JSON.stringify(safe.value)
179
+ )
180
+ safe.state = "redacted";
181
+ return safe as T;
182
+ }
package/src/index.ts CHANGED
@@ -4,6 +4,7 @@ export {
4
4
  SERIALIZED_SYSTEM_ACTOR,
5
5
  serializeActor,
6
6
  } from "./actor.js";
7
+ export { orderDependencies } from "./dependency-order.js";
7
8
  export type {
8
9
  Actor,
9
10
  CurrentExecutionRef,
@@ -21,6 +22,11 @@ export type {
21
22
  LaunchOrigin,
22
23
  LaunchRun,
23
24
  LaunchRunStatus,
25
+ MappedItem,
26
+ MappedItemStatus,
27
+ MappedRun,
28
+ MappedRunStatus,
29
+ MappedTurnItemRef,
24
30
  ModelSelectionKind,
25
31
  ModelSelectionProvenance,
26
32
  NormalizedQuestion,
@@ -82,6 +88,8 @@ export {
82
88
  SYSTEM_ACTOR,
83
89
  WORKER_ERROR_CLASSES,
84
90
  } from "./domain-model.js";
91
+ export * from "./execution-inspection.js";
92
+ export { resolveJsonPointer } from "./json-pointer.js";
85
93
  export {
86
94
  addLauncherRecentValue,
87
95
  DEFAULT_LAUNCHER_RECENT_VALUE_LIMIT,
@@ -99,6 +107,7 @@ export type {
99
107
  ProcessFlowEdge,
100
108
  ProcessFlowEndState,
101
109
  ProcessFlowNode,
110
+ ProcessFlowTool,
102
111
  ProcessFlowView,
103
112
  ProcessTurnTerminalLifecycleStatus,
104
113
  ProcessTurnTransition,
@@ -112,6 +121,7 @@ export {
112
121
  parseStrictInstanceTurnConfigsJson,
113
122
  serializeInstanceTurnConfigs,
114
123
  } from "./process-model-config.js";
124
+ export { shortestSuccessfulTurnPath } from "./process-path.js";
115
125
  export {
116
126
  buildProcessRowSlot,
117
127
  type ProcessRowSlot,
@@ -133,6 +143,14 @@ export {
133
143
  detectRepoLocatorKind,
134
144
  parseRepoLocator,
135
145
  } from "./repo-locator.js";
146
+ export type {
147
+ ResolvedSetting,
148
+ ScopedSettingsSnapshot,
149
+ SettingsContext,
150
+ SettingsOverride,
151
+ SettingsSource,
152
+ SettingsSubject,
153
+ } from "./scoped-settings.js";
136
154
  export {
137
155
  areSemanticEntryRefsEqual,
138
156
  assertValidProcessProductName,
@@ -0,0 +1,10 @@
1
+ /** Resolve a validated JSON Pointer through own properties only. @internal */
2
+ export function resolveJsonPointer(value: unknown, pointer: string): unknown {
3
+ if (pointer === "") return value;
4
+ for (const token of pointer.slice(1).split("/")) {
5
+ const key = token.replaceAll("~1", "/").replaceAll("~0", "~");
6
+ if (!value || typeof value !== "object" || !Object.hasOwn(value, key)) return undefined;
7
+ value = (value as Record<string, unknown>)[key];
8
+ }
9
+ return value;
10
+ }
@@ -30,7 +30,7 @@ export interface SerializedProcessGraph {
30
30
  turnTransitions: Record<TurnId, ProcessTurnTransition[]>;
31
31
  }
32
32
 
33
- /** Whether a flow node sits on the declared happy path (`spine`) or hangs off it (`branch`). @internal */
33
+ /** Whether a flow node sits on the shortest successful path or a side branch. @internal */
34
34
  export type ProcessFlowNodeRole = "spine" | "branch";
35
35
 
36
36
  /**
@@ -43,6 +43,16 @@ export type ProcessFlowNodeRole = "spine" | "branch";
43
43
  /** @internal */
44
44
  export type ProcessFlowEdgeKind = "forward" | "loopback" | "branch" | "terminal";
45
45
 
46
+ /** A statically declared LLM tool, without executable code or runtime credentials. @internal */
47
+ export interface ProcessFlowTool {
48
+ /** @internal */
49
+ name: string;
50
+ /** @internal */
51
+ category: "workspace" | "integration" | "question" | "outcome";
52
+ /** Declared description when available; integration registrations are resolved separately. @internal */
53
+ description: string | null;
54
+ }
55
+
46
56
  /** @internal */
47
57
  export interface ProcessFlowNode {
48
58
  /** @internal */
@@ -59,6 +69,16 @@ export interface ProcessFlowNode {
59
69
  anchorTurnId: TurnId | null;
60
70
  /** True when this turn is a launch entry point. @internal */
61
71
  isEntry: boolean;
72
+ /** One logical turn applied to frozen items, followed by internal collection. @internal */
73
+ repetition?: "sequential";
74
+ /** Static declarations only; absent on non-LLM turns and older projections. @internal */
75
+ tools?: ProcessFlowTool[];
76
+ /** Additional integration tool names are resolved from process data at turn start. @internal */
77
+ hasDynamicTools?: boolean;
78
+ /** Named product declarations, not execution-time values. @internal */
79
+ inputProducts?: string[];
80
+ /** Named products this turn can publish. @internal */
81
+ outputProducts?: string[];
62
82
  }
63
83
 
64
84
  /** @internal */
@@ -73,6 +93,11 @@ export interface ProcessFlowEdge {
73
93
  kind: ProcessFlowEdgeKind;
74
94
  /** Optional human-facing edge label derived from outcome/trigger metadata. @internal */
75
95
  label: string | null;
96
+ /** Declared branch condition; inspecting the graph never evaluates its chooser. @internal */
97
+ condition?: {
98
+ /** @internal */ label: string;
99
+ /** @internal */ description?: string;
100
+ };
76
101
  }
77
102
 
78
103
  /** @internal */
@@ -88,8 +113,9 @@ export interface ProcessFlowEndState {
88
113
  }
89
114
 
90
115
  /**
91
- * Spine-first projection of a process graph for operator-facing flow diagrams.
92
- * The `spine` is the happy path; everything else hangs off it as branches and loops.
116
+ * Complete definition projection for operator-facing flow diagrams.
117
+ * The `spine` is the shortest path from the primary entry to completion.
118
+ * Operator decisions remain explicit; collection stays inside a mapped turn.
93
119
  */
94
120
  /** @internal */
95
121
  export interface ProcessFlowView {