@caupulican/pi-adaptative 0.90.2 → 0.90.4

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 (162) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/core/agent-session-contracts.d.ts +2 -0
  3. package/dist/core/agent-session-contracts.d.ts.map +1 -1
  4. package/dist/core/agent-session-contracts.js.map +1 -1
  5. package/dist/core/autonomy/bounded-completion.d.ts +10 -1
  6. package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
  7. package/dist/core/autonomy/bounded-completion.js +24 -2
  8. package/dist/core/autonomy/bounded-completion.js.map +1 -1
  9. package/dist/core/autonomy/lane-tracker.d.ts +1 -1
  10. package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
  11. package/dist/core/autonomy/lane-tracker.js +9 -1
  12. package/dist/core/autonomy/lane-tracker.js.map +1 -1
  13. package/dist/core/background-lane-controller.d.ts +1 -3
  14. package/dist/core/background-lane-controller.d.ts.map +1 -1
  15. package/dist/core/background-lane-controller.js.map +1 -1
  16. package/dist/core/compaction-controller.d.ts.map +1 -1
  17. package/dist/core/compaction-controller.js +0 -1
  18. package/dist/core/compaction-controller.js.map +1 -1
  19. package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -1
  20. package/dist/core/delegation/managed-lane-controller.js +5 -1
  21. package/dist/core/delegation/managed-lane-controller.js.map +1 -1
  22. package/dist/core/delegation/worker-agent-control-coordinator.d.ts +8 -1
  23. package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
  24. package/dist/core/delegation/worker-agent-control-coordinator.js +94 -36
  25. package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
  26. package/dist/core/delegation/worker-agent-control.d.ts +1 -0
  27. package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
  28. package/dist/core/delegation/worker-agent-control.js.map +1 -1
  29. package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
  30. package/dist/core/delegation/worker-attempt-executor.js +7 -2
  31. package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
  32. package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
  33. package/dist/core/delegation/worker-authority-resolver.js +26 -3
  34. package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
  35. package/dist/core/delegation/worker-delegation-controller.d.ts +7 -4
  36. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
  37. package/dist/core/delegation/worker-delegation-controller.js +110 -27
  38. package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
  39. package/dist/core/delegation/worker-fleet-limits.d.ts +9 -2
  40. package/dist/core/delegation/worker-fleet-limits.d.ts.map +1 -1
  41. package/dist/core/delegation/worker-fleet-limits.js +39 -3
  42. package/dist/core/delegation/worker-fleet-limits.js.map +1 -1
  43. package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -1
  44. package/dist/core/delegation/worker-lane-projection.js +4 -0
  45. package/dist/core/delegation/worker-lane-projection.js.map +1 -1
  46. package/dist/core/delegation/worker-lease-heartbeat.d.ts +16 -0
  47. package/dist/core/delegation/worker-lease-heartbeat.d.ts.map +1 -0
  48. package/dist/core/delegation/worker-lease-heartbeat.js +37 -0
  49. package/dist/core/delegation/worker-lease-heartbeat.js.map +1 -0
  50. package/dist/core/delegation/worker-lifecycle.d.ts +1 -0
  51. package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
  52. package/dist/core/delegation/worker-lifecycle.js +6 -0
  53. package/dist/core/delegation/worker-lifecycle.js.map +1 -1
  54. package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
  55. package/dist/core/delegation/worker-notification-coordinator.js +2 -1
  56. package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
  57. package/dist/core/delegation/worker-runner.js +2 -2
  58. package/dist/core/delegation/worker-runner.js.map +1 -1
  59. package/dist/core/delegation/worker-terminal-handoff-coordinator.d.ts +1 -0
  60. package/dist/core/delegation/worker-terminal-handoff-coordinator.d.ts.map +1 -1
  61. package/dist/core/delegation/worker-terminal-handoff-coordinator.js +1 -0
  62. package/dist/core/delegation/worker-terminal-handoff-coordinator.js.map +1 -1
  63. package/dist/core/delegation/worker-tree-budget-coordinator.d.ts +4 -2
  64. package/dist/core/delegation/worker-tree-budget-coordinator.d.ts.map +1 -1
  65. package/dist/core/delegation/worker-tree-budget-coordinator.js +10 -2
  66. package/dist/core/delegation/worker-tree-budget-coordinator.js.map +1 -1
  67. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts +14 -0
  68. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -1
  69. package/dist/core/delegation/worker-write-reservation-coordinator.js +121 -33
  70. package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -1
  71. package/dist/core/foreground-terminal-handoff-controller.d.ts +5 -0
  72. package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -1
  73. package/dist/core/foreground-terminal-handoff-controller.js +28 -12
  74. package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
  75. package/dist/core/orchestration/capability-gateway.d.ts +2 -1
  76. package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
  77. package/dist/core/orchestration/capability-gateway.js +9 -2
  78. package/dist/core/orchestration/capability-gateway.js.map +1 -1
  79. package/dist/core/orchestration/contracts.d.ts +16 -1
  80. package/dist/core/orchestration/contracts.d.ts.map +1 -1
  81. package/dist/core/orchestration/contracts.js +5 -0
  82. package/dist/core/orchestration/contracts.js.map +1 -1
  83. package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
  84. package/dist/core/orchestration/profile-registry.js +38 -1
  85. package/dist/core/orchestration/profile-registry.js.map +1 -1
  86. package/dist/core/orchestration/risk-budget.d.ts +10 -0
  87. package/dist/core/orchestration/risk-budget.d.ts.map +1 -1
  88. package/dist/core/orchestration/risk-budget.js +14 -0
  89. package/dist/core/orchestration/risk-budget.js.map +1 -1
  90. package/dist/core/orchestration/task-runtime-reducer.d.ts +1 -0
  91. package/dist/core/orchestration/task-runtime-reducer.d.ts.map +1 -1
  92. package/dist/core/orchestration/task-runtime-reducer.js +34 -0
  93. package/dist/core/orchestration/task-runtime-reducer.js.map +1 -1
  94. package/dist/core/orchestration/task-runtime.d.ts +1 -0
  95. package/dist/core/orchestration/task-runtime.d.ts.map +1 -1
  96. package/dist/core/orchestration/task-runtime.js +24 -1
  97. package/dist/core/orchestration/task-runtime.js.map +1 -1
  98. package/dist/core/provider-prompt-contracts.d.ts.map +1 -1
  99. package/dist/core/provider-prompt-contracts.js +2 -1
  100. package/dist/core/provider-prompt-contracts.js.map +1 -1
  101. package/dist/core/reflection-controller.d.ts.map +1 -1
  102. package/dist/core/reflection-controller.js +8 -1
  103. package/dist/core/reflection-controller.js.map +1 -1
  104. package/dist/core/settings-manager.d.ts +2 -2
  105. package/dist/core/settings-manager.d.ts.map +1 -1
  106. package/dist/core/settings-manager.js +2 -2
  107. package/dist/core/settings-manager.js.map +1 -1
  108. package/dist/core/tools/bash.d.ts +3 -0
  109. package/dist/core/tools/bash.d.ts.map +1 -1
  110. package/dist/core/tools/bash.js +13 -2
  111. package/dist/core/tools/bash.js.map +1 -1
  112. package/dist/core/tools/delegate-status.d.ts +1 -0
  113. package/dist/core/tools/delegate-status.d.ts.map +1 -1
  114. package/dist/core/tools/delegate-status.js +19 -1
  115. package/dist/core/tools/delegate-status.js.map +1 -1
  116. package/dist/core/tools/delegate.d.ts +9 -1
  117. package/dist/core/tools/delegate.d.ts.map +1 -1
  118. package/dist/core/tools/delegate.js +198 -64
  119. package/dist/core/tools/delegate.js.map +1 -1
  120. package/dist/core/tools/edit.d.ts.map +1 -1
  121. package/dist/core/tools/edit.js +14 -1
  122. package/dist/core/tools/edit.js.map +1 -1
  123. package/dist/core/tools/file-failure-recovery.d.ts +3 -0
  124. package/dist/core/tools/file-failure-recovery.d.ts.map +1 -1
  125. package/dist/core/tools/file-failure-recovery.js +11 -0
  126. package/dist/core/tools/file-failure-recovery.js.map +1 -1
  127. package/dist/core/tools/orchestration-panel.d.ts +1 -1
  128. package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
  129. package/dist/core/tools/orchestration-panel.js +1 -0
  130. package/dist/core/tools/orchestration-panel.js.map +1 -1
  131. package/dist/core/tools/profile-writer.d.ts.map +1 -1
  132. package/dist/core/tools/profile-writer.js +2 -8
  133. package/dist/core/tools/profile-writer.js.map +1 -1
  134. package/dist/core/tools/search-command-guard.d.ts.map +1 -1
  135. package/dist/core/tools/search-command-guard.js +10 -3
  136. package/dist/core/tools/search-command-guard.js.map +1 -1
  137. package/dist/core/tools/write.d.ts.map +1 -1
  138. package/dist/core/tools/write.js +10 -1
  139. package/dist/core/tools/write.js.map +1 -1
  140. package/dist/modes/interactive/components/activity-lane.d.ts +1 -1
  141. package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
  142. package/dist/modes/interactive/components/activity-lane.js +11 -2
  143. package/dist/modes/interactive/components/activity-lane.js.map +1 -1
  144. package/dist/modes/interactive/components/settings-selector.js +1 -1
  145. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  146. package/dist/utils/shell.d.ts +2 -0
  147. package/dist/utils/shell.d.ts.map +1 -1
  148. package/dist/utils/shell.js +3 -1
  149. package/dist/utils/shell.js.map +1 -1
  150. package/docs/harness-architecture.md +6 -3
  151. package/docs/settings.md +8 -6
  152. package/docs/tool-repair.md +1 -1
  153. package/docs/worker-profiles.md +2 -2
  154. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  155. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  156. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  157. package/examples/extensions/sandbox/package-lock.json +2 -2
  158. package/examples/extensions/sandbox/package.json +1 -1
  159. package/examples/extensions/with-deps/package-lock.json +2 -2
  160. package/examples/extensions/with-deps/package.json +1 -1
  161. package/npm-shrinkwrap.json +12 -12
  162. package/package.json +4 -4
@@ -31,6 +31,10 @@ export declare const MAX_ORCHESTRATION_NOTIFICATIONS = 512;
31
31
  export declare const MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE = 512;
32
32
  export declare const MAX_ORCHESTRATION_EVIDENCE = 4096;
33
33
  export declare const MAX_ORCHESTRATION_CHECKPOINT_SUMMARY_LENGTH: number;
34
+ /** Absolute durable lineage bound enforced even when a profile requests broader recursion. */
35
+ export declare const MAX_ORCHESTRATION_AGENT_DEPTH = 8;
36
+ /** Retained direct-child identity bound enforced even when a profile requests broader fan-out. */
37
+ export declare const MAX_ORCHESTRATION_DIRECT_CHILDREN = 64;
34
38
  /** One changed retained map value; aggregate projection accounting remains the authoritative ceiling. */
35
39
  export declare const MAX_ORCHESTRATION_RETAINED_RECORD_BYTES: number;
36
40
  /** Leaves room for bounded idempotency evidence and the snapshot envelope below the on-disk ceiling. */
@@ -61,6 +65,15 @@ export interface OrchestrationExecutionPolicy {
61
65
  allowedEnvironmentVariables: readonly string[];
62
66
  maxOutputBytes: number;
63
67
  }
68
+ /** Outbound recursive delegation authority retained with an immutable worker profile snapshot. */
69
+ export interface OrchestrationDelegationLimits {
70
+ /** Greatest absolute AgentBindingContract.depth that this worker may create. */
71
+ maxDepth: number;
72
+ /** Greatest number of retained direct child identities that this worker may create. */
73
+ maxChildrenPerAgent: number;
74
+ /** Greatest number of retained non-root identities across this durable session. */
75
+ maxNestedAgentsPerSession?: number;
76
+ }
64
77
  export declare const OBJECTIVE_STATUSES: readonly ["active", "paused", "completed", "cancelled"];
65
78
  export type ObjectiveStatus = (typeof OBJECTIVE_STATUSES)[number];
66
79
  export declare const TASK_STATUSES: readonly ["pending", "ready", "running", "blocked", "completed", "failed", "cancelled"];
@@ -188,6 +201,8 @@ export interface OrchestrationProfile {
188
201
  /** Optional preset-routing metadata retained for authored profiles; never an admission allowlist. */
189
202
  dispatchProfileIds: readonly string[];
190
203
  executionPolicy?: OrchestrationExecutionPolicy;
204
+ /** Omitted authored profiles use the host ceiling; adaptive profiles carry a lean explicit limit. */
205
+ delegationLimits?: OrchestrationDelegationLimits;
191
206
  budget: RiskBudget;
192
207
  /** Authored scheduling hint retained in the snapshot; the global scheduler owns actual concurrency. */
193
208
  maxConcurrent: number;
@@ -394,7 +409,7 @@ export interface ApprovalResolutionContract {
394
409
  reasonCode: string;
395
410
  resolvedAt: string;
396
411
  }
397
- export declare const ORCHESTRATION_EVENT_TYPES: readonly ["objective.created", "objective.updated", "objective.evidence_recorded", "objective.paused", "objective.resumed", "objective.completed", "objective.cancelled", "task.created", "task.attempt_prepared", "task.ready", "task.failed", "task.verification_finished", "agent.registered", "agent.retired", "agent.suspended", "agent.resume_requested", "agent.resumed", "attempt.queued", "attempt.grant_bound", "attempt.leased", "attempt.started", "attempt.checkpointed", "attempt.suspended", "attempt.resumed", "attempt.cancelled", "attempt.finished", "attempt.lease_expired", "approval.requested", "approval.resolved", "notification.enqueued", "notification.delivered"];
412
+ export declare const ORCHESTRATION_EVENT_TYPES: readonly ["objective.created", "objective.updated", "objective.evidence_recorded", "objective.paused", "objective.resumed", "objective.completed", "objective.cancelled", "task.created", "task.attempt_prepared", "task.ready", "task.failed", "task.verification_finished", "agent.registered", "agent.retired", "agent.suspended", "agent.resume_requested", "agent.resumed", "attempt.queued", "attempt.grant_bound", "attempt.leased", "attempt.started", "attempt.lease_renewed", "attempt.checkpointed", "attempt.suspended", "attempt.resumed", "attempt.cancelled", "attempt.finished", "attempt.lease_expired", "approval.requested", "approval.resolved", "notification.enqueued", "notification.delivered"];
398
413
  export type OrchestrationEventType = (typeof ORCHESTRATION_EVENT_TYPES)[number];
399
414
  export type OrchestrationActorKind = "human" | "kernel" | "runtime" | "policy" | "router" | "worker";
400
415
  export interface OrchestrationEvent {
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAwB,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEzF,OAAO,KAAK,E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AO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,sBAAsB,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,sBAAsB,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,6BAA6B;IAC7C,IAAI,EAAE,sBAAsB,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,sBAAsB,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,UAAU,CAAC;CACpB;AAmBD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAE9E;AAED,qGAAqG;AACrG,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAKvD;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAiBhF"}
@@ -30,6 +30,10 @@ export const MAX_ORCHESTRATION_NOTIFICATIONS = 512;
30
30
  export const MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE = 512;
31
31
  export const MAX_ORCHESTRATION_EVIDENCE = 4_096;
32
32
  export const MAX_ORCHESTRATION_CHECKPOINT_SUMMARY_LENGTH = 4 * 1024;
33
+ /** Absolute durable lineage bound enforced even when a profile requests broader recursion. */
34
+ export const MAX_ORCHESTRATION_AGENT_DEPTH = 8;
35
+ /** Retained direct-child identity bound enforced even when a profile requests broader fan-out. */
36
+ export const MAX_ORCHESTRATION_DIRECT_CHILDREN = 64;
33
37
  /** One changed retained map value; aggregate projection accounting remains the authoritative ceiling. */
34
38
  export const MAX_ORCHESTRATION_RETAINED_RECORD_BYTES = 1024 * 1024;
35
39
  /** Leaves room for bounded idempotency evidence and the snapshot envelope below the on-disk ceiling. */
@@ -115,6 +119,7 @@ export const ORCHESTRATION_EVENT_TYPES = [
115
119
  "attempt.grant_bound",
116
120
  "attempt.leased",
117
121
  "attempt.started",
122
+ "attempt.lease_renewed",
118
123
  "attempt.checkpointed",
119
124
  "attempt.suspended",
120
125
  "attempt.resumed",
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/core/orchestration/contracts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAA0B,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAAE,oBAAoB,EAA0B,MAAM,2BAA2B,CAAC;AAEzF;;;;GAIG;AAEH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAU,CAAC;AAEvD,yGAAyG;AACzG,MAAM,CAAC,MAAM,mCAAmC,GAAG,GAAG,CAAC;AACvD,MAAM,CAAC,MAAM,uCAAuC,GAAG,GAAG,CAAC;AAC3D,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,CAAC;AACrD,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAAC,GAAG,IAAI,CAAC;AAC7D,MAAM,CAAC,MAAM,mCAAmC,GAAG,EAAE,CAAC;AACtD,MAAM,CAAC,MAAM,8CAA8C,GAAG,EAAE,GAAG,IAAI,CAAC;AACxE;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAG,CAAC;AACpD,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAChD,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAC9C,MAAM,CAAC,MAAM,6BAA6B,GAAG,KAAK,CAAC;AACnD,MAAM,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5B,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAC1B,CAAC;AACH,CAAC","sourcesContent":["import type { JsonObject, JsonValue } from \"../autonomy/contracts.ts\";\nimport { HARNESS_CAPABILITIES, type HarnessCapability } from \"../capability-contract.ts\";\nimport { isPlainRecord } from \"../util/value-guards.ts\";\nimport type { WorkerContextForkReference } from \"./worker-context-fork-reference.ts\";\n\nexport { HARNESS_CAPABILITIES, type HarnessCapability } from \"../capability-contract.ts\";\n\n/**\n * Versioned control-plane contracts. These records are the durable truth exchanged between the\n * deterministic kernel/runtime and replaceable execution-plane workers. They deliberately do not\n * contain callbacks, provider objects, tool implementations, or transcript messages.\n */\n\nexport const ORCHESTRATION_SCHEMA_VERSION = 1 as const;\n\n/** Shared durable-control bounds. Keep persisted orchestration records small enough to replay safely. */\nexport const MAX_ORCHESTRATION_IDENTIFIER_LENGTH = 512;\nexport const MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH = 128;\nexport const MAX_ORCHESTRATION_MODEL_ID_LENGTH = 512;\nexport const MAX_ORCHESTRATION_DESCRIPTION_LENGTH = 4 * 1024;\nexport const MAX_ORCHESTRATION_COLLECTION_LENGTH = 64;\nexport const MAX_ORCHESTRATION_DISPATCH_INSTRUCTIONS_LENGTH = 16 * 1024;\n/**\n * Lifetime ceilings for the retained hot projection. Terminal records are intentionally retained,\n * so these limits match the durable worker-fleet ceiling rather than only counting active work.\n */\nexport const MAX_ORCHESTRATION_AGENT_BINDINGS = 256;\nexport const MAX_ORCHESTRATION_OBJECTIVES = 256;\nexport const MAX_ORCHESTRATION_TASKS = 256;\nexport const MAX_ORCHESTRATION_ATTEMPTS = 256;\nexport const MAX_ORCHESTRATION_CHECKPOINTS = 4_096;\nexport const MAX_ORCHESTRATION_APPROVALS = 256;\n/** Approval prompts and terminal handoffs may each retain one notification per attempt. */\nexport const MAX_ORCHESTRATION_NOTIFICATIONS = 512;\n/** Source goal state admits at most 512 evidence entries for one objective. */\nexport const MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE = 512;\nexport const MAX_ORCHESTRATION_EVIDENCE = 4_096;\nexport const MAX_ORCHESTRATION_CHECKPOINT_SUMMARY_LENGTH = 4 * 1024;\n/** One changed retained map value; aggregate projection accounting remains the authoritative ceiling. */\nexport const MAX_ORCHESTRATION_RETAINED_RECORD_BYTES = 1024 * 1024;\n/** Leaves room for bounded idempotency evidence and the snapshot envelope below the on-disk ceiling. */\nexport const MAX_ORCHESTRATION_PROJECTION_BYTES = 24 * 1024 * 1024;\nexport const MAX_ORCHESTRATION_SNAPSHOT_IDEMPOTENCY_BYTES = 4 * 1024 * 1024;\nexport const MAX_ORCHESTRATION_PROJECTION_SNAPSHOT_BYTES = 32 * 1024 * 1024;\n/** Matches the bounded worker/process result contract retained by the execution plane. */\nexport const MAX_ORCHESTRATION_PROCESS_OUTPUT_BYTES = 512 * 1024;\nexport const MAX_WORKER_AUTHORITY_PATHS = 64;\nexport const MAX_WORKER_AUTHORITY_PATH_LENGTH = 4 * 1024;\nexport const MAX_WORKER_SOUL_LENGTH = 16 * 1024;\n\nexport const WORKER_ROLES = [\n\t\"orchestrator\",\n\t\"planner\",\n\t\"explorer\",\n\t\"implementer\",\n\t\"operator\",\n\t\"verifier\",\n\t\"database\",\n] as const;\nexport type WorkerRole = (typeof WORKER_ROLES)[number];\n\nexport const ORCHESTRATION_THINKING_LEVELS = [\n\t\"off\",\n\t\"minimal\",\n\t\"low\",\n\t\"medium\",\n\t\"high\",\n\t\"xhigh\",\n\t\"max\",\n\t\"ultra\",\n] as const;\nexport type OrchestrationThinkingLevel = (typeof ORCHESTRATION_THINKING_LEVELS)[number];\n\nexport interface OrchestrationModelBinding {\n\tprovider: string;\n\tmodelId: string;\n\tthinkingLevel: OrchestrationThinkingLevel;\n}\n\nexport interface OrchestrationModelPolicy {\n\tmode: \"fixed\" | \"ordered-fallback\";\n\tcandidates: readonly OrchestrationModelBinding[];\n}\n\n/** Constrained direct-argv launcher policy. This is allowlisting, not OS/container isolation. */\nexport interface OrchestrationExecutionPolicy {\n\tallowedExecutables: readonly string[];\n\tallowedEnvironmentVariables: readonly string[];\n\tmaxOutputBytes: number;\n}\n\nexport const OBJECTIVE_STATUSES = [\"active\", \"paused\", \"completed\", \"cancelled\"] as const;\nexport type ObjectiveStatus = (typeof OBJECTIVE_STATUSES)[number];\n\nexport const TASK_STATUSES = [\"pending\", \"ready\", \"running\", \"blocked\", \"completed\", \"failed\", \"cancelled\"] as const;\nexport type OrchestrationTaskStatus = (typeof TASK_STATUSES)[number];\n\nexport const ATTEMPT_STATUSES = [\n\t\"queued\",\n\t\"leased\",\n\t\"running\",\n\t\"suspended\",\n\t\"completed\",\n\t\"partial\",\n\t\"blocked\",\n\t\"failed\",\n\t\"cancelled\",\n\t\"expired\",\n] as const;\nexport type AttemptStatus = (typeof ATTEMPT_STATUSES)[number];\n\nexport const WORKER_RESULT_STATUSES = [\"completed\", \"partial\", \"blocked\", \"failed\", \"cancelled\"] as const;\nexport type WorkerResultContractStatus = (typeof WORKER_RESULT_STATUSES)[number];\n\nexport type AgentBindingStatus = \"registered\" | \"active\" | \"suspended\" | \"resuming\" | \"retired\";\n\nexport interface AgentResumeContext {\n\tprovider: \"pi\" | \"external\";\n\tsessionId: string;\n\tsessionDir?: string;\n\tsessionFile?: string;\n\tcwd: string;\n\tworktreeLaneKey?: string;\n\torchestrationProfileId?: string;\n\tresourceProfileNames: readonly string[];\n\tmodelRef?: string;\n\tcontextPointers: readonly ResourcePointer[];\n\tlatestCheckpointId?: string;\n}\n\n/** Provider-neutral logical identity shared by durable orchestration and process supervision. */\nexport interface AgentIdentityContract {\n\tagentId: string;\n\tresumeContext: AgentResumeContext;\n}\n\n/** Durable logical identity. A replacement OS process resumes this same binding after interruption. */\nexport interface AgentBindingContract extends AgentIdentityContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\t/** Direct creator in the durable orchestration tree. Root agents omit this field. */\n\tparentAgentId?: string;\n\t/** Stable root identity retained across bounded recursive delegation depth. */\n\trootAgentId: string;\n\t/** Durable lineage depth. Fleet admission enforces the host-configured depth ceiling. */\n\tdepth: number;\n\trole: WorkerRole;\n\tstatus: AgentBindingStatus;\n\tactiveAttemptId?: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface RiskBudget {\n\t/**\n\t * Budget-counted tokens, not raw provider totals: input/output/cache-write tokens charge at\n\t * face value, prompt-cache reads at CACHE_READ_BUDGET_WEIGHT (see capability-gateway.ts).\n\t * Charging cache reads fully would turn this into a request counter, since every request\n\t * re-reads the fixed system prompt.\n\t */\n\tmaxTokens?: number;\n\tmaxWallClockMs?: number;\n\tmaxCostUsd?: number;\n\tmaxAttempts?: number;\n\tmaxToolCalls?: number;\n\trequireApprovalAboveCostUsd?: number;\n}\n\nexport interface AcceptanceCriterion {\n\tid: string;\n\tdescription: string;\n\trequired: boolean;\n\tevaluator?: string;\n}\n\nexport interface ObjectiveContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tobjectiveId: string;\n\ttitle: string;\n\tdescription: string;\n\tstatus: ObjectiveStatus;\n\tconstraints: readonly string[];\n\tacceptanceCriteria: readonly AcceptanceCriterion[];\n\triskBudget: RiskBudget;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface TaskContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\ttaskId: string;\n\tobjectiveId: string;\n\ttitle: string;\n\tdescription: string;\n\trole: WorkerRole;\n\tstatus: OrchestrationTaskStatus;\n\tdependsOn: readonly string[];\n\trequiredCapabilities: readonly HarnessCapability[];\n\tacceptanceCriterionIds: readonly string[];\n\t/** Implementer task this verifier task must independently reconcile. */\n\tverificationOfTaskId?: string;\n\triskBudget: RiskBudget;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport const RESOURCE_POINTER_KINDS = [\n\t\"repository\",\n\t\"worktree\",\n\t\"artifact\",\n\t\"evidence\",\n\t\"memory-query\",\n\t\"skill\",\n\t\"prompt\",\n\t\"service\",\n] as const;\nexport type ResourcePointerKind = (typeof RESOURCE_POINTER_KINDS)[number];\n\nexport function isResourcePointerKind(value: unknown): value is ResourcePointerKind {\n\treturn RESOURCE_POINTER_KINDS.some((kind) => kind === value);\n}\n\nexport interface ResourcePointer {\n\tid: string;\n\tkind: ResourcePointerKind;\n\turi: string;\n\treadOnly: boolean;\n\tdigest?: string;\n\tmetadata?: JsonObject;\n}\n\n/** Bounded metadata-only resources retained in one worker execution contract. */\nexport const MAX_WORKER_RESOURCE_POINTERS = 64;\nexport const MAX_WORKER_RESOURCE_PATH_LENGTH = 4096;\nexport const MAX_WORKER_RESOURCE_METADATA_NAME_LENGTH = 256;\n\n/** Lightweight metadata catalogued without importing the executable tool module. */\nexport interface ToolCapabilityManifest {\n\ttoolName: string;\n\tmoduleSpecifier: string;\n\tcapabilities: readonly HarnessCapability[];\n\troles: readonly WorkerRole[];\n\tenforcements: readonly CapabilityEnforcementKind[];\n\tsourcePath?: string;\n}\n\nexport interface OrchestrationProfile {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tprofileId: string;\n\tdescription: string;\n\trole: WorkerRole;\n\tmodelPolicy: OrchestrationModelPolicy;\n\tcapabilityCeiling: readonly HarnessCapability[];\n\ttoolNames: readonly string[];\n\tresourceProfileNames: readonly string[];\n\t/** Optional preset-routing metadata retained for authored profiles; never an admission allowlist. */\n\tdispatchProfileIds: readonly string[];\n\texecutionPolicy?: OrchestrationExecutionPolicy;\n\tbudget: RiskBudget;\n\t/** Authored scheduling hint retained in the snapshot; the global scheduler owns actual concurrency. */\n\tmaxConcurrent: number;\n\tleaseTtlMs: number;\n\trequireIndependentVerification: boolean;\n\t/** Owner-pinned verifier profile. Required when independent verification is enabled. */\n\tverificationProfileId?: string;\n\t/** Resolved origin retained for controlled improvements; omitted from authored JSON. */\n\tsourcePath?: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\n/** Admission-time worker profile materialization. Profile files are never consulted after this is persisted. */\nexport interface WorkerProfileExecutionContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tprofile: OrchestrationProfile;\n\tmodelBinding: OrchestrationModelBinding;\n\tauthority: WorkerExecutionAuthorityContract;\n\t/** Metadata-only resources fixed at admission; their content remains lazy and non-durable. */\n\tresourcePointers: readonly ResourcePointer[];\n\t/** Resolved resource-profile identity text. Other worker resources are represented by profile tools. */\n\tsoul?: string;\n}\n\n/** Effective authority admitted for one materialized worker profile. */\nexport interface WorkerExecutionAuthorityContract {\n\tcapabilities: readonly HarnessCapability[];\n\ttoolNames: readonly string[];\n\treadPaths: readonly string[];\n\twritePaths: readonly string[];\n\tdeniedPaths: readonly string[];\n\tbudget: RiskBudget;\n}\n\n/** Immutable execution contract owned by the runtime, including any mandatory verifier. */\nexport interface WorkerExecutionContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tworker: WorkerProfileExecutionContract;\n\tverifier?: WorkerProfileExecutionContract;\n}\n\n/** Durable dispatch metadata. Model/tool choices are retained in the runtime-owned executionContract. */\nexport interface OrchestrationDispatchRequest {\n\ttaskId: string;\n\tprofileId: string;\n\tinstructions: string;\n\tresourcePointerIds: readonly string[];\n\t/** Direct logical-agent creator for recursively delegated in-process work. */\n\tparentAgentId?: string;\n\t/** Runtime-owned goal/task correlation. Omitted by legacy records and normalized to an empty list. */\n\trequirementIds?: readonly string[];\n\t/** Execution owner. Omitted on legacy records and normalized to in-process. */\n\texecutionKind?: \"in-process\" | \"managed-process\";\n\t/** Stable external lane identity shared by successive managed-process turns. */\n\tlogicalLaneId?: string;\n\t/** Monotonic dispatch sequence within a managed-process logical lane. */\n\tdispatchSequence?: number;\n\t/** Durable mailbox message whose task-bearing intent owns this logical-agent turn. */\n\tcontrolMessageId?: string;\n\t/** External provider identity retained for routing and diagnostics. */\n\tprovider?: string;\n\t/** Owner approval or standing-grant record that authorized an external launch. */\n\tauthorizationId?: string;\n\t/** Worktree-sync lane claimed by the external dispatcher. */\n\tworktreeLaneKey?: string;\n\t/** Immutable sanitized parent context captured for this persistent logical worker at birth. */\n\tbirthContextForkReference?: WorkerContextForkReference;\n\t/** Runtime-owned immutable worker materialization. Never accepted from a model tool call. */\n\texecutionContract?: WorkerExecutionContract;\n}\n\nexport type CapabilityEnforcementKind =\n\t| \"path-scope\"\n\t| \"process-launcher\"\n\t| \"service-proxy\"\n\t| \"memory-broker\"\n\t| \"control-plane\";\n\nexport interface CapabilityDecision {\n\tcapability: HarnessCapability;\n\toutcome: \"allow\" | \"deny\";\n\treasonCode: string;\n\tsource: string;\n}\n\nexport interface ExecutionGrant {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tgrantId: string;\n\tobjectiveId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tsubjectId: string;\n\trole: WorkerRole;\n\tcapabilities: readonly HarnessCapability[];\n\tallowedTools: readonly string[];\n\tresources: readonly ResourcePointer[];\n\treadPaths: readonly string[];\n\twritePaths: readonly string[];\n\tdeniedPaths: readonly string[];\n\tbudget: RiskBudget;\n\tpolicyVersion: string;\n\tdecisionTrace: readonly CapabilityDecision[];\n\tissuedAt: string;\n\texpiresAt?: string;\n}\n\nexport interface AttemptLease {\n\tleaseId: string;\n\tattemptId: string;\n\townerId: string;\n\tfencingToken: number;\n\tissuedAt: string;\n\texpiresAt: string;\n}\n\n/** Restart-durable host retry ladder state for one resumable worker attempt. */\nexport interface AttemptRetryState {\n\t/** Scheduled retries already consumed; the initial execution is not included. */\n\tretriesUsed: number;\n\t/** Earliest instant at which the suspended attempt may receive a fresh lease. */\n\tnotBefore: string;\n}\n\n/** Complete cumulative active usage for one execution attempt. Restart downtime is never included. */\nexport interface AttemptUsageSnapshot {\n\ttoolCalls: number;\n\tinputTokens: number;\n\toutputTokens: number;\n\tcacheReadTokens: number;\n\tcacheWriteTokens: number;\n\t/** Provider-authoritative total; detail categories are not assumed to be additive. */\n\ttotalTokens: number;\n\tcostUsd: number;\n\tactiveWallClockMs: number;\n}\n\nexport interface AttemptCheckpoint {\n\tcheckpointId: string;\n\tattemptId: string;\n\tfencingToken: number;\n\tsummary: string;\n\tartifactIds: readonly string[];\n\tevidenceIds: readonly string[];\n\t/** Omitted only by legacy checkpoints created before durable usage accounting existed. */\n\tusage?: AttemptUsageSnapshot;\n\tcreatedAt: string;\n}\n\nexport interface ArtifactContract {\n\tartifactId: string;\n\tkind: \"diff\" | \"file\" | \"report\" | \"test-result\" | \"log\" | \"structured-data\";\n\turi: string;\n\tdigest?: string;\n\tsizeBytes?: number;\n\tcreatedAt: string;\n\tmetadata?: JsonObject;\n}\n\nexport interface EvidenceContract {\n\tevidenceId: string;\n\tcriterionId?: string;\n\tkind: \"observation\" | \"command\" | \"test\" | \"review\" | \"external\";\n\tsummary: string;\n\tartifactIds: readonly string[];\n\ttrusted: boolean;\n\tcreatedAt: string;\n\tmetadata?: JsonObject;\n}\n\nexport interface WorkerErrorContract {\n\tcode: string;\n\tmessage: string;\n\tretryable: boolean;\n\tdetails?: JsonObject;\n}\n\nexport interface WorkerUsageContract {\n\tinputTokens?: number;\n\toutputTokens?: number;\n\ttotalTokens?: number;\n\tcostUsd?: number;\n\twallClockMs: number;\n\ttoolCalls: number;\n}\n\nexport interface WorkerResultContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tresultId: string;\n\tobjectiveId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tleaseId: string;\n\tfencingToken: number;\n\tstatus: WorkerResultContractStatus;\n\treasonCode: string;\n\tsummary: string;\n\tartifacts: readonly ArtifactContract[];\n\tevidence: readonly EvidenceContract[];\n\terrors: readonly WorkerErrorContract[];\n\tnextAction?: string;\n\tusage: WorkerUsageContract;\n\tcreatedAt: string;\n}\n\nexport interface ApprovalRequestContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tapprovalId: string;\n\tobjectiveId: string;\n\ttaskId?: string;\n\tattemptId?: string;\n\treasonCode: string;\n\tsummary: string;\n\trequestedCapabilities: readonly HarnessCapability[];\n\trequestedBudget?: RiskBudget;\n\treversible: boolean;\n\tcreatedAt: string;\n}\n\nexport const APPROVAL_OUTCOMES = [\"approved\", \"rejected\"] as const;\nexport type ApprovalOutcome = (typeof APPROVAL_OUTCOMES)[number];\n\n/** Human decision only. Approval is not an execution grant; policy must compile a new grant afterward. */\nexport interface ApprovalResolutionContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tapprovalId: string;\n\toutcome: ApprovalOutcome;\n\treasonCode: string;\n\tresolvedAt: string;\n}\n\nexport const ORCHESTRATION_EVENT_TYPES = [\n\t\"objective.created\",\n\t\"objective.updated\",\n\t\"objective.evidence_recorded\",\n\t\"objective.paused\",\n\t\"objective.resumed\",\n\t\"objective.completed\",\n\t\"objective.cancelled\",\n\t\"task.created\",\n\t\"task.attempt_prepared\",\n\t\"task.ready\",\n\t\"task.failed\",\n\t\"task.verification_finished\",\n\t\"agent.registered\",\n\t\"agent.retired\",\n\t\"agent.suspended\",\n\t\"agent.resume_requested\",\n\t\"agent.resumed\",\n\t\"attempt.queued\",\n\t\"attempt.grant_bound\",\n\t\"attempt.leased\",\n\t\"attempt.started\",\n\t\"attempt.checkpointed\",\n\t\"attempt.suspended\",\n\t\"attempt.resumed\",\n\t\"attempt.cancelled\",\n\t\"attempt.finished\",\n\t\"attempt.lease_expired\",\n\t\"approval.requested\",\n\t\"approval.resolved\",\n\t\"notification.enqueued\",\n\t\"notification.delivered\",\n] as const;\n\nexport type OrchestrationEventType = (typeof ORCHESTRATION_EVENT_TYPES)[number];\nexport type OrchestrationActorKind = \"human\" | \"kernel\" | \"runtime\" | \"policy\" | \"router\" | \"worker\";\n\nexport interface OrchestrationEvent {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tordinal: number;\n\teventId: string;\n\ttype: OrchestrationEventType;\n\taggregateId: string;\n\tactor: OrchestrationActorKind;\n\toccurredAt: string;\n\tcorrelationId?: string;\n\tcausationId?: string;\n\tidempotencyKey?: string;\n\tpayload: JsonObject;\n}\n\nexport interface AppendOrchestrationEventInput {\n\ttype: OrchestrationEventType;\n\taggregateId: string;\n\tactor: OrchestrationActorKind;\n\tcorrelationId?: string;\n\tcausationId?: string;\n\tidempotencyKey?: string;\n\tpayload: JsonObject;\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n\treturn typeof value === \"string\" && value.length > 0;\n}\n\nfunction isJsonValue(value: unknown, depth = 0): value is JsonValue {\n\tif (depth > 30) return false;\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return true;\n\tif (typeof value === \"number\") return Number.isFinite(value);\n\tif (Array.isArray(value)) return value.every((entry) => isJsonValue(entry, depth + 1));\n\tif (!isPlainRecord(value)) return false;\n\treturn Object.values(value).every((entry) => isJsonValue(entry, depth + 1));\n}\n\nfunction includesString<const T extends readonly string[]>(values: T, value: unknown): value is T[number] {\n\treturn typeof value === \"string\" && values.includes(value);\n}\n\nexport function isHarnessCapability(value: unknown): value is HarnessCapability {\n\treturn includesString(HARNESS_CAPABILITIES, value);\n}\n\n/** Clone a runtime value into the persisted JSON domain, rejecting unsupported or over-deep data. */\nexport function toJsonObject(value: unknown): JsonObject {\n\tif (!isPlainRecord(value) || !isJsonValue(value)) {\n\t\tthrow new TypeError(\"Value is not a valid orchestration JSON object.\");\n\t}\n\treturn structuredClone(value);\n}\n\nexport function isOrchestrationEvent(value: unknown): value is OrchestrationEvent {\n\tif (!isPlainRecord(value)) return false;\n\treturn (\n\t\tvalue.schemaVersion === ORCHESTRATION_SCHEMA_VERSION &&\n\t\tNumber.isSafeInteger(value.ordinal) &&\n\t\tNumber(value.ordinal) > 0 &&\n\t\tisNonEmptyString(value.eventId) &&\n\t\tincludesString(ORCHESTRATION_EVENT_TYPES, value.type) &&\n\t\tisNonEmptyString(value.aggregateId) &&\n\t\tincludesString([\"human\", \"kernel\", \"runtime\", \"policy\", \"router\", \"worker\"] as const, value.actor) &&\n\t\tisNonEmptyString(value.occurredAt) &&\n\t\t(value.correlationId === undefined || isNonEmptyString(value.correlationId)) &&\n\t\t(value.causationId === undefined || isNonEmptyString(value.causationId)) &&\n\t\t(value.idempotencyKey === undefined || isNonEmptyString(value.idempotencyKey)) &&\n\t\tisPlainRecord(value.payload) &&\n\t\tisJsonValue(value.payload)\n\t);\n}\n"]}
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/core/orchestration/contracts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAA0B,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAAE,oBAAoB,EAA0B,MAAM,2BAA2B,CAAC;AAEzF;;;;GAIG;AAEH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAU,CAAC;AAEvD,yGAAyG;AACzG,MAAM,CAAC,MAAM,mCAAmC,GAAG,GAAG,CAAC;AACvD,MAAM,CAAC,MAAM,uCAAuC,GAAG,GAAG,CAAC;AAC3D,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,CAAC;AACrD,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAAC,GAAG,IAAI,CAAC;AAC7D,MAAM,CAAC,MAAM,mCAAmC,GAAG,EAAE,CAAC;AACtD,MAAM,CAAC,MAAM,8CAA8C,GAAG,EAAE,GAAG,IAAI,CAAC;AACxE;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAG,CAAC;AACpD,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAChD,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAC9C,MAAM,CAAC,MAAM,6BAA6B,GAAG,KAAK,CAAC;AACnD,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAC/C,2FAA2F;AAC3F,MAAM,C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,KAAK,CAAC,cAAc,CAAC,CAAC;QAC9E,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC;QAC5B,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAC1B,CAAC;AACH,CAAC","sourcesContent":["import type { JsonObject, JsonValue } from \"../autonomy/contracts.ts\";\nimport { HARNESS_CAPABILITIES, type HarnessCapability } from \"../capability-contract.ts\";\nimport { isPlainRecord } from \"../util/value-guards.ts\";\nimport type { WorkerContextForkReference } from \"./worker-context-fork-reference.ts\";\n\nexport { HARNESS_CAPABILITIES, type HarnessCapability } from \"../capability-contract.ts\";\n\n/**\n * Versioned control-plane contracts. These records are the durable truth exchanged between the\n * deterministic kernel/runtime and replaceable execution-plane workers. They deliberately do not\n * contain callbacks, provider objects, tool implementations, or transcript messages.\n */\n\nexport const ORCHESTRATION_SCHEMA_VERSION = 1 as const;\n\n/** Shared durable-control bounds. Keep persisted orchestration records small enough to replay safely. */\nexport const MAX_ORCHESTRATION_IDENTIFIER_LENGTH = 512;\nexport const MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH = 128;\nexport const MAX_ORCHESTRATION_MODEL_ID_LENGTH = 512;\nexport const MAX_ORCHESTRATION_DESCRIPTION_LENGTH = 4 * 1024;\nexport const MAX_ORCHESTRATION_COLLECTION_LENGTH = 64;\nexport const MAX_ORCHESTRATION_DISPATCH_INSTRUCTIONS_LENGTH = 16 * 1024;\n/**\n * Lifetime ceilings for the retained hot projection. Terminal records are intentionally retained,\n * so these limits match the durable worker-fleet ceiling rather than only counting active work.\n */\nexport const MAX_ORCHESTRATION_AGENT_BINDINGS = 256;\nexport const MAX_ORCHESTRATION_OBJECTIVES = 256;\nexport const MAX_ORCHESTRATION_TASKS = 256;\nexport const MAX_ORCHESTRATION_ATTEMPTS = 256;\nexport const MAX_ORCHESTRATION_CHECKPOINTS = 4_096;\nexport const MAX_ORCHESTRATION_APPROVALS = 256;\n/** Approval prompts and terminal handoffs may each retain one notification per attempt. */\nexport const MAX_ORCHESTRATION_NOTIFICATIONS = 512;\n/** Source goal state admits at most 512 evidence entries for one objective. */\nexport const MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE = 512;\nexport const MAX_ORCHESTRATION_EVIDENCE = 4_096;\nexport const MAX_ORCHESTRATION_CHECKPOINT_SUMMARY_LENGTH = 4 * 1024;\n/** Absolute durable lineage bound enforced even when a profile requests broader recursion. */\nexport const MAX_ORCHESTRATION_AGENT_DEPTH = 8;\n/** Retained direct-child identity bound enforced even when a profile requests broader fan-out. */\nexport const MAX_ORCHESTRATION_DIRECT_CHILDREN = 64;\n/** One changed retained map value; aggregate projection accounting remains the authoritative ceiling. */\nexport const MAX_ORCHESTRATION_RETAINED_RECORD_BYTES = 1024 * 1024;\n/** Leaves room for bounded idempotency evidence and the snapshot envelope below the on-disk ceiling. */\nexport const MAX_ORCHESTRATION_PROJECTION_BYTES = 24 * 1024 * 1024;\nexport const MAX_ORCHESTRATION_SNAPSHOT_IDEMPOTENCY_BYTES = 4 * 1024 * 1024;\nexport const MAX_ORCHESTRATION_PROJECTION_SNAPSHOT_BYTES = 32 * 1024 * 1024;\n/** Matches the bounded worker/process result contract retained by the execution plane. */\nexport const MAX_ORCHESTRATION_PROCESS_OUTPUT_BYTES = 512 * 1024;\nexport const MAX_WORKER_AUTHORITY_PATHS = 64;\nexport const MAX_WORKER_AUTHORITY_PATH_LENGTH = 4 * 1024;\nexport const MAX_WORKER_SOUL_LENGTH = 16 * 1024;\n\nexport const WORKER_ROLES = [\n\t\"orchestrator\",\n\t\"planner\",\n\t\"explorer\",\n\t\"implementer\",\n\t\"operator\",\n\t\"verifier\",\n\t\"database\",\n] as const;\nexport type WorkerRole = (typeof WORKER_ROLES)[number];\n\nexport const ORCHESTRATION_THINKING_LEVELS = [\n\t\"off\",\n\t\"minimal\",\n\t\"low\",\n\t\"medium\",\n\t\"high\",\n\t\"xhigh\",\n\t\"max\",\n\t\"ultra\",\n] as const;\nexport type OrchestrationThinkingLevel = (typeof ORCHESTRATION_THINKING_LEVELS)[number];\n\nexport interface OrchestrationModelBinding {\n\tprovider: string;\n\tmodelId: string;\n\tthinkingLevel: OrchestrationThinkingLevel;\n}\n\nexport interface OrchestrationModelPolicy {\n\tmode: \"fixed\" | \"ordered-fallback\";\n\tcandidates: readonly OrchestrationModelBinding[];\n}\n\n/** Constrained direct-argv launcher policy. This is allowlisting, not OS/container isolation. */\nexport interface OrchestrationExecutionPolicy {\n\tallowedExecutables: readonly string[];\n\tallowedEnvironmentVariables: readonly string[];\n\tmaxOutputBytes: number;\n}\n\n/** Outbound recursive delegation authority retained with an immutable worker profile snapshot. */\nexport interface OrchestrationDelegationLimits {\n\t/** Greatest absolute AgentBindingContract.depth that this worker may create. */\n\tmaxDepth: number;\n\t/** Greatest number of retained direct child identities that this worker may create. */\n\tmaxChildrenPerAgent: number;\n\t/** Greatest number of retained non-root identities across this durable session. */\n\tmaxNestedAgentsPerSession?: number;\n}\n\nexport const OBJECTIVE_STATUSES = [\"active\", \"paused\", \"completed\", \"cancelled\"] as const;\nexport type ObjectiveStatus = (typeof OBJECTIVE_STATUSES)[number];\n\nexport const TASK_STATUSES = [\"pending\", \"ready\", \"running\", \"blocked\", \"completed\", \"failed\", \"cancelled\"] as const;\nexport type OrchestrationTaskStatus = (typeof TASK_STATUSES)[number];\n\nexport const ATTEMPT_STATUSES = [\n\t\"queued\",\n\t\"leased\",\n\t\"running\",\n\t\"suspended\",\n\t\"completed\",\n\t\"partial\",\n\t\"blocked\",\n\t\"failed\",\n\t\"cancelled\",\n\t\"expired\",\n] as const;\nexport type AttemptStatus = (typeof ATTEMPT_STATUSES)[number];\n\nexport const WORKER_RESULT_STATUSES = [\"completed\", \"partial\", \"blocked\", \"failed\", \"cancelled\"] as const;\nexport type WorkerResultContractStatus = (typeof WORKER_RESULT_STATUSES)[number];\n\nexport type AgentBindingStatus = \"registered\" | \"active\" | \"suspended\" | \"resuming\" | \"retired\";\n\nexport interface AgentResumeContext {\n\tprovider: \"pi\" | \"external\";\n\tsessionId: string;\n\tsessionDir?: string;\n\tsessionFile?: string;\n\tcwd: string;\n\tworktreeLaneKey?: string;\n\torchestrationProfileId?: string;\n\tresourceProfileNames: readonly string[];\n\tmodelRef?: string;\n\tcontextPointers: readonly ResourcePointer[];\n\tlatestCheckpointId?: string;\n}\n\n/** Provider-neutral logical identity shared by durable orchestration and process supervision. */\nexport interface AgentIdentityContract {\n\tagentId: string;\n\tresumeContext: AgentResumeContext;\n}\n\n/** Durable logical identity. A replacement OS process resumes this same binding after interruption. */\nexport interface AgentBindingContract extends AgentIdentityContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\t/** Direct creator in the durable orchestration tree. Root agents omit this field. */\n\tparentAgentId?: string;\n\t/** Stable root identity retained across bounded recursive delegation depth. */\n\trootAgentId: string;\n\t/** Durable lineage depth. Fleet admission enforces the host-configured depth ceiling. */\n\tdepth: number;\n\trole: WorkerRole;\n\tstatus: AgentBindingStatus;\n\tactiveAttemptId?: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface RiskBudget {\n\t/**\n\t * Budget-counted tokens, not raw provider totals: input/output/cache-write tokens charge at\n\t * face value, prompt-cache reads at CACHE_READ_BUDGET_WEIGHT (see capability-gateway.ts).\n\t * Charging cache reads fully would turn this into a request counter, since every request\n\t * re-reads the fixed system prompt.\n\t */\n\tmaxTokens?: number;\n\tmaxWallClockMs?: number;\n\tmaxCostUsd?: number;\n\tmaxAttempts?: number;\n\tmaxToolCalls?: number;\n\trequireApprovalAboveCostUsd?: number;\n}\n\nexport interface AcceptanceCriterion {\n\tid: string;\n\tdescription: string;\n\trequired: boolean;\n\tevaluator?: string;\n}\n\nexport interface ObjectiveContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tobjectiveId: string;\n\ttitle: string;\n\tdescription: string;\n\tstatus: ObjectiveStatus;\n\tconstraints: readonly string[];\n\tacceptanceCriteria: readonly AcceptanceCriterion[];\n\triskBudget: RiskBudget;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface TaskContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\ttaskId: string;\n\tobjectiveId: string;\n\ttitle: string;\n\tdescription: string;\n\trole: WorkerRole;\n\tstatus: OrchestrationTaskStatus;\n\tdependsOn: readonly string[];\n\trequiredCapabilities: readonly HarnessCapability[];\n\tacceptanceCriterionIds: readonly string[];\n\t/** Implementer task this verifier task must independently reconcile. */\n\tverificationOfTaskId?: string;\n\triskBudget: RiskBudget;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport const RESOURCE_POINTER_KINDS = [\n\t\"repository\",\n\t\"worktree\",\n\t\"artifact\",\n\t\"evidence\",\n\t\"memory-query\",\n\t\"skill\",\n\t\"prompt\",\n\t\"service\",\n] as const;\nexport type ResourcePointerKind = (typeof RESOURCE_POINTER_KINDS)[number];\n\nexport function isResourcePointerKind(value: unknown): value is ResourcePointerKind {\n\treturn RESOURCE_POINTER_KINDS.some((kind) => kind === value);\n}\n\nexport interface ResourcePointer {\n\tid: string;\n\tkind: ResourcePointerKind;\n\turi: string;\n\treadOnly: boolean;\n\tdigest?: string;\n\tmetadata?: JsonObject;\n}\n\n/** Bounded metadata-only resources retained in one worker execution contract. */\nexport const MAX_WORKER_RESOURCE_POINTERS = 64;\nexport const MAX_WORKER_RESOURCE_PATH_LENGTH = 4096;\nexport const MAX_WORKER_RESOURCE_METADATA_NAME_LENGTH = 256;\n\n/** Lightweight metadata catalogued without importing the executable tool module. */\nexport interface ToolCapabilityManifest {\n\ttoolName: string;\n\tmoduleSpecifier: string;\n\tcapabilities: readonly HarnessCapability[];\n\troles: readonly WorkerRole[];\n\tenforcements: readonly CapabilityEnforcementKind[];\n\tsourcePath?: string;\n}\n\nexport interface OrchestrationProfile {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tprofileId: string;\n\tdescription: string;\n\trole: WorkerRole;\n\tmodelPolicy: OrchestrationModelPolicy;\n\tcapabilityCeiling: readonly HarnessCapability[];\n\ttoolNames: readonly string[];\n\tresourceProfileNames: readonly string[];\n\t/** Optional preset-routing metadata retained for authored profiles; never an admission allowlist. */\n\tdispatchProfileIds: readonly string[];\n\texecutionPolicy?: OrchestrationExecutionPolicy;\n\t/** Omitted authored profiles use the host ceiling; adaptive profiles carry a lean explicit limit. */\n\tdelegationLimits?: OrchestrationDelegationLimits;\n\tbudget: RiskBudget;\n\t/** Authored scheduling hint retained in the snapshot; the global scheduler owns actual concurrency. */\n\tmaxConcurrent: number;\n\tleaseTtlMs: number;\n\trequireIndependentVerification: boolean;\n\t/** Owner-pinned verifier profile. Required when independent verification is enabled. */\n\tverificationProfileId?: string;\n\t/** Resolved origin retained for controlled improvements; omitted from authored JSON. */\n\tsourcePath?: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\n/** Admission-time worker profile materialization. Profile files are never consulted after this is persisted. */\nexport interface WorkerProfileExecutionContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tprofile: OrchestrationProfile;\n\tmodelBinding: OrchestrationModelBinding;\n\tauthority: WorkerExecutionAuthorityContract;\n\t/** Metadata-only resources fixed at admission; their content remains lazy and non-durable. */\n\tresourcePointers: readonly ResourcePointer[];\n\t/** Resolved resource-profile identity text. Other worker resources are represented by profile tools. */\n\tsoul?: string;\n}\n\n/** Effective authority admitted for one materialized worker profile. */\nexport interface WorkerExecutionAuthorityContract {\n\tcapabilities: readonly HarnessCapability[];\n\ttoolNames: readonly string[];\n\treadPaths: readonly string[];\n\twritePaths: readonly string[];\n\tdeniedPaths: readonly string[];\n\tbudget: RiskBudget;\n}\n\n/** Immutable execution contract owned by the runtime, including any mandatory verifier. */\nexport interface WorkerExecutionContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tworker: WorkerProfileExecutionContract;\n\tverifier?: WorkerProfileExecutionContract;\n}\n\n/** Durable dispatch metadata. Model/tool choices are retained in the runtime-owned executionContract. */\nexport interface OrchestrationDispatchRequest {\n\ttaskId: string;\n\tprofileId: string;\n\tinstructions: string;\n\tresourcePointerIds: readonly string[];\n\t/** Direct logical-agent creator for recursively delegated in-process work. */\n\tparentAgentId?: string;\n\t/** Runtime-owned goal/task correlation. Omitted by legacy records and normalized to an empty list. */\n\trequirementIds?: readonly string[];\n\t/** Execution owner. Omitted on legacy records and normalized to in-process. */\n\texecutionKind?: \"in-process\" | \"managed-process\";\n\t/** Stable external lane identity shared by successive managed-process turns. */\n\tlogicalLaneId?: string;\n\t/** Monotonic dispatch sequence within a managed-process logical lane. */\n\tdispatchSequence?: number;\n\t/** Durable mailbox message whose task-bearing intent owns this logical-agent turn. */\n\tcontrolMessageId?: string;\n\t/** External provider identity retained for routing and diagnostics. */\n\tprovider?: string;\n\t/** Owner approval or standing-grant record that authorized an external launch. */\n\tauthorizationId?: string;\n\t/** Worktree-sync lane claimed by the external dispatcher. */\n\tworktreeLaneKey?: string;\n\t/** Immutable sanitized parent context captured for this persistent logical worker at birth. */\n\tbirthContextForkReference?: WorkerContextForkReference;\n\t/** Runtime-owned immutable worker materialization. Never accepted from a model tool call. */\n\texecutionContract?: WorkerExecutionContract;\n}\n\nexport type CapabilityEnforcementKind =\n\t| \"path-scope\"\n\t| \"process-launcher\"\n\t| \"service-proxy\"\n\t| \"memory-broker\"\n\t| \"control-plane\";\n\nexport interface CapabilityDecision {\n\tcapability: HarnessCapability;\n\toutcome: \"allow\" | \"deny\";\n\treasonCode: string;\n\tsource: string;\n}\n\nexport interface ExecutionGrant {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tgrantId: string;\n\tobjectiveId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tsubjectId: string;\n\trole: WorkerRole;\n\tcapabilities: readonly HarnessCapability[];\n\tallowedTools: readonly string[];\n\tresources: readonly ResourcePointer[];\n\treadPaths: readonly string[];\n\twritePaths: readonly string[];\n\tdeniedPaths: readonly string[];\n\tbudget: RiskBudget;\n\tpolicyVersion: string;\n\tdecisionTrace: readonly CapabilityDecision[];\n\tissuedAt: string;\n\texpiresAt?: string;\n}\n\nexport interface AttemptLease {\n\tleaseId: string;\n\tattemptId: string;\n\townerId: string;\n\tfencingToken: number;\n\tissuedAt: string;\n\texpiresAt: string;\n}\n\n/** Restart-durable host retry ladder state for one resumable worker attempt. */\nexport interface AttemptRetryState {\n\t/** Scheduled retries already consumed; the initial execution is not included. */\n\tretriesUsed: number;\n\t/** Earliest instant at which the suspended attempt may receive a fresh lease. */\n\tnotBefore: string;\n}\n\n/** Complete cumulative active usage for one execution attempt. Restart downtime is never included. */\nexport interface AttemptUsageSnapshot {\n\ttoolCalls: number;\n\tinputTokens: number;\n\toutputTokens: number;\n\tcacheReadTokens: number;\n\tcacheWriteTokens: number;\n\t/** Provider-authoritative total; detail categories are not assumed to be additive. */\n\ttotalTokens: number;\n\tcostUsd: number;\n\tactiveWallClockMs: number;\n}\n\nexport interface AttemptCheckpoint {\n\tcheckpointId: string;\n\tattemptId: string;\n\tfencingToken: number;\n\tsummary: string;\n\tartifactIds: readonly string[];\n\tevidenceIds: readonly string[];\n\t/** Omitted only by legacy checkpoints created before durable usage accounting existed. */\n\tusage?: AttemptUsageSnapshot;\n\tcreatedAt: string;\n}\n\nexport interface ArtifactContract {\n\tartifactId: string;\n\tkind: \"diff\" | \"file\" | \"report\" | \"test-result\" | \"log\" | \"structured-data\";\n\turi: string;\n\tdigest?: string;\n\tsizeBytes?: number;\n\tcreatedAt: string;\n\tmetadata?: JsonObject;\n}\n\nexport interface EvidenceContract {\n\tevidenceId: string;\n\tcriterionId?: string;\n\tkind: \"observation\" | \"command\" | \"test\" | \"review\" | \"external\";\n\tsummary: string;\n\tartifactIds: readonly string[];\n\ttrusted: boolean;\n\tcreatedAt: string;\n\tmetadata?: JsonObject;\n}\n\nexport interface WorkerErrorContract {\n\tcode: string;\n\tmessage: string;\n\tretryable: boolean;\n\tdetails?: JsonObject;\n}\n\nexport interface WorkerUsageContract {\n\tinputTokens?: number;\n\toutputTokens?: number;\n\ttotalTokens?: number;\n\tcostUsd?: number;\n\twallClockMs: number;\n\ttoolCalls: number;\n}\n\nexport interface WorkerResultContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tresultId: string;\n\tobjectiveId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tleaseId: string;\n\tfencingToken: number;\n\tstatus: WorkerResultContractStatus;\n\treasonCode: string;\n\tsummary: string;\n\tartifacts: readonly ArtifactContract[];\n\tevidence: readonly EvidenceContract[];\n\terrors: readonly WorkerErrorContract[];\n\tnextAction?: string;\n\tusage: WorkerUsageContract;\n\tcreatedAt: string;\n}\n\nexport interface ApprovalRequestContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tapprovalId: string;\n\tobjectiveId: string;\n\ttaskId?: string;\n\tattemptId?: string;\n\treasonCode: string;\n\tsummary: string;\n\trequestedCapabilities: readonly HarnessCapability[];\n\trequestedBudget?: RiskBudget;\n\treversible: boolean;\n\tcreatedAt: string;\n}\n\nexport const APPROVAL_OUTCOMES = [\"approved\", \"rejected\"] as const;\nexport type ApprovalOutcome = (typeof APPROVAL_OUTCOMES)[number];\n\n/** Human decision only. Approval is not an execution grant; policy must compile a new grant afterward. */\nexport interface ApprovalResolutionContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tapprovalId: string;\n\toutcome: ApprovalOutcome;\n\treasonCode: string;\n\tresolvedAt: string;\n}\n\nexport const ORCHESTRATION_EVENT_TYPES = [\n\t\"objective.created\",\n\t\"objective.updated\",\n\t\"objective.evidence_recorded\",\n\t\"objective.paused\",\n\t\"objective.resumed\",\n\t\"objective.completed\",\n\t\"objective.cancelled\",\n\t\"task.created\",\n\t\"task.attempt_prepared\",\n\t\"task.ready\",\n\t\"task.failed\",\n\t\"task.verification_finished\",\n\t\"agent.registered\",\n\t\"agent.retired\",\n\t\"agent.suspended\",\n\t\"agent.resume_requested\",\n\t\"agent.resumed\",\n\t\"attempt.queued\",\n\t\"attempt.grant_bound\",\n\t\"attempt.leased\",\n\t\"attempt.started\",\n\t\"attempt.lease_renewed\",\n\t\"attempt.checkpointed\",\n\t\"attempt.suspended\",\n\t\"attempt.resumed\",\n\t\"attempt.cancelled\",\n\t\"attempt.finished\",\n\t\"attempt.lease_expired\",\n\t\"approval.requested\",\n\t\"approval.resolved\",\n\t\"notification.enqueued\",\n\t\"notification.delivered\",\n] as const;\n\nexport type OrchestrationEventType = (typeof ORCHESTRATION_EVENT_TYPES)[number];\nexport type OrchestrationActorKind = \"human\" | \"kernel\" | \"runtime\" | \"policy\" | \"router\" | \"worker\";\n\nexport interface OrchestrationEvent {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tordinal: number;\n\teventId: string;\n\ttype: OrchestrationEventType;\n\taggregateId: string;\n\tactor: OrchestrationActorKind;\n\toccurredAt: string;\n\tcorrelationId?: string;\n\tcausationId?: string;\n\tidempotencyKey?: string;\n\tpayload: JsonObject;\n}\n\nexport interface AppendOrchestrationEventInput {\n\ttype: OrchestrationEventType;\n\taggregateId: string;\n\tactor: OrchestrationActorKind;\n\tcorrelationId?: string;\n\tcausationId?: string;\n\tidempotencyKey?: string;\n\tpayload: JsonObject;\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n\treturn typeof value === \"string\" && value.length > 0;\n}\n\nfunction isJsonValue(value: unknown, depth = 0): value is JsonValue {\n\tif (depth > 30) return false;\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return true;\n\tif (typeof value === \"number\") return Number.isFinite(value);\n\tif (Array.isArray(value)) return value.every((entry) => isJsonValue(entry, depth + 1));\n\tif (!isPlainRecord(value)) return false;\n\treturn Object.values(value).every((entry) => isJsonValue(entry, depth + 1));\n}\n\nfunction includesString<const T extends readonly string[]>(values: T, value: unknown): value is T[number] {\n\treturn typeof value === \"string\" && values.includes(value);\n}\n\nexport function isHarnessCapability(value: unknown): value is HarnessCapability {\n\treturn includesString(HARNESS_CAPABILITIES, value);\n}\n\n/** Clone a runtime value into the persisted JSON domain, rejecting unsupported or over-deep data. */\nexport function toJsonObject(value: unknown): JsonObject {\n\tif (!isPlainRecord(value) || !isJsonValue(value)) {\n\t\tthrow new TypeError(\"Value is not a valid orchestration JSON object.\");\n\t}\n\treturn structuredClone(value);\n}\n\nexport function isOrchestrationEvent(value: unknown): value is OrchestrationEvent {\n\tif (!isPlainRecord(value)) return false;\n\treturn (\n\t\tvalue.schemaVersion === ORCHESTRATION_SCHEMA_VERSION &&\n\t\tNumber.isSafeInteger(value.ordinal) &&\n\t\tNumber(value.ordinal) > 0 &&\n\t\tisNonEmptyString(value.eventId) &&\n\t\tincludesString(ORCHESTRATION_EVENT_TYPES, value.type) &&\n\t\tisNonEmptyString(value.aggregateId) &&\n\t\tincludesString([\"human\", \"kernel\", \"runtime\", \"policy\", \"router\", \"worker\"] as const, value.actor) &&\n\t\tisNonEmptyString(value.occurredAt) &&\n\t\t(value.correlationId === undefined || isNonEmptyString(value.correlationId)) &&\n\t\t(value.causationId === undefined || isNonEmptyString(value.causationId)) &&\n\t\t(value.idempotencyKey === undefined || isNonEmptyString(value.idempotencyKey)) &&\n\t\tisPlainRecord(value.payload) &&\n\t\tisJsonValue(value.payload)\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"profile-registry.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/profile-registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,cAAc,EACd,4BAA4B,EAC5B,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EAEf,YAAY,EACZ,sBAAsB,EACtB,MAAM,gBAAgB,CAAC;AAiBxB,OAAO,EAGN,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,MAAM,sBAAsB,CAAC;AAG9B,MAAM,WAAW,eAAe;IAC/B,SAAS,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC;CACvD;AAED,MAA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ACzC,OAAO,EAAE,4BAA4B,CAAC;IACtC,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,4BAA4B,CAAC;IACvC,MAAM,EAAE,eAAe,CAAC;IACxB,cAAc,EAAE,uBAAuB,CAAC;IACxC,aAAa,EAAE,SAAS,sBAAsB,EAAE,CAAC;IACjD,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;IACtC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,aAAa,EAAE,MAAM,CAAC;CACtB,GAAG,yBAAyB,CAoC5B"}
1
+ {"version":3,"file":"profile-registry.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/profile-registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,cAAc,EACd,4BAA4B,EAC5B,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EAEf,YAAY,EACZ,sBAAsB,EACtB,MAAM,gBAAgB,CAAC;AAoBxB,OAAO,EAGN,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,MAAM,sBAAsB,CAAC;AAG9B,MAAM,WAAW,eAAe;IAC/B,SAAS,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC;CACvD;AAED,MAAM,WAAW,mBAAmB;IACnC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,KAAK,EAAE,yBAAyB,CAAC;IACjC,KAAK,EAAE,cAAc,CAAC;IACtB,aAAa,EAAE,SAAS,sBAAsB,EAAE,CAAC;CACjD;AAED,MAAM,MAAM,yBAAyB,GAClC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,mBAAmB,CAAA;CAAE,GAC/C,OAAO,CAAC,uBAAuB,EAAE;IAAE,OAAO,EAAE,OAAO,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,SAAS,MAAM,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,aAAa,EAAE,MAAM,CAAC;CACtB,GAAG,yBAAyB,CAoC5B"}
@@ -1,6 +1,6 @@
1
1
  import { describeToolCapabilityAuthority, resolveProfileToolCapability } from "../tool-capability-policy.js";
2
2
  import { hasOnlyKeys, isPlainRecord } from "../util/value-guards.js";
3
- import { HARNESS_CAPABILITIES, MAX_ORCHESTRATION_COLLECTION_LENGTH, MAX_ORCHESTRATION_DESCRIPTION_LENGTH, MAX_ORCHESTRATION_DISPATCH_INSTRUCTIONS_LENGTH, MAX_ORCHESTRATION_IDENTIFIER_LENGTH, MAX_ORCHESTRATION_MODEL_ID_LENGTH, MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH, MAX_ORCHESTRATION_PROCESS_OUTPUT_BYTES, MAX_WORKER_AUTHORITY_PATH_LENGTH, ORCHESTRATION_SCHEMA_VERSION, ORCHESTRATION_THINKING_LEVELS, toJsonObject, WORKER_ROLES, } from "./contracts.js";
3
+ import { HARNESS_CAPABILITIES, MAX_ORCHESTRATION_AGENT_BINDINGS, MAX_ORCHESTRATION_AGENT_DEPTH, MAX_ORCHESTRATION_COLLECTION_LENGTH, MAX_ORCHESTRATION_DESCRIPTION_LENGTH, MAX_ORCHESTRATION_DIRECT_CHILDREN, MAX_ORCHESTRATION_DISPATCH_INSTRUCTIONS_LENGTH, MAX_ORCHESTRATION_IDENTIFIER_LENGTH, MAX_ORCHESTRATION_MODEL_ID_LENGTH, MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH, MAX_ORCHESTRATION_PROCESS_OUTPUT_BYTES, MAX_WORKER_AUTHORITY_PATH_LENGTH, ORCHESTRATION_SCHEMA_VERSION, ORCHESTRATION_THINKING_LEVELS, toJsonObject, WORKER_ROLES, } from "./contracts.js";
4
4
  import { ORCHESTRATION_PROFILE_TOOL_NAMES } from "./lane-tool-manifests.js";
5
5
  import { DEFAULT_ROLE_CAPABILITY_CEILINGS, } from "./policy-compiler.js";
6
6
  import { parseRiskBudget, validateRiskBudget } from "./risk-budget.js";
@@ -129,6 +129,19 @@ export function validateOrchestrationProfile(profile) {
129
129
  if (!Number.isSafeInteger(profile.leaseTtlMs) || profile.leaseTtlMs <= 0) {
130
130
  throw new OrchestrationProfileError(`Profile '${profile.profileId}' leaseTtlMs must be positive.`);
131
131
  }
132
+ if (profile.delegationLimits &&
133
+ (!Number.isSafeInteger(profile.delegationLimits.maxDepth) ||
134
+ profile.delegationLimits.maxDepth < 0 ||
135
+ profile.delegationLimits.maxDepth > MAX_ORCHESTRATION_AGENT_DEPTH ||
136
+ !Number.isSafeInteger(profile.delegationLimits.maxChildrenPerAgent) ||
137
+ profile.delegationLimits.maxChildrenPerAgent < 0 ||
138
+ profile.delegationLimits.maxChildrenPerAgent > MAX_ORCHESTRATION_DIRECT_CHILDREN ||
139
+ (profile.delegationLimits.maxNestedAgentsPerSession !== undefined &&
140
+ (!Number.isSafeInteger(profile.delegationLimits.maxNestedAgentsPerSession) ||
141
+ profile.delegationLimits.maxNestedAgentsPerSession < 0 ||
142
+ profile.delegationLimits.maxNestedAgentsPerSession > MAX_ORCHESTRATION_AGENT_BINDINGS)))) {
143
+ throw new OrchestrationProfileError(`Profile '${profile.profileId}' delegationLimits are invalid.`);
144
+ }
132
145
  try {
133
146
  validateRiskBudget(profile.budget, `Profile '${profile.profileId}' budget`);
134
147
  }
@@ -192,6 +205,7 @@ export function parseOrchestrationProfile(value, sourcePath) {
192
205
  "resourceProfileNames",
193
206
  "dispatchProfileIds",
194
207
  "executionPolicy",
208
+ "delegationLimits",
195
209
  "budget",
196
210
  "maxConcurrent",
197
211
  "leaseTtlMs",
@@ -206,6 +220,7 @@ export function parseOrchestrationProfile(value, sourcePath) {
206
220
  const rawBudget = value.budget;
207
221
  let budget;
208
222
  const executionPolicy = value.executionPolicy;
223
+ const delegationLimits = value.delegationLimits;
209
224
  if (!isPlainRecord(modelPolicy) ||
210
225
  !hasOnlyKeys(modelPolicy, ["mode", "candidates"]) ||
211
226
  !Array.isArray(modelPolicy.candidates) ||
@@ -226,6 +241,15 @@ export function parseOrchestrationProfile(value, sourcePath) {
226
241
  !Number.isSafeInteger(executionPolicy.maxOutputBytes))) {
227
242
  throw new OrchestrationProfileError("Orchestration profile executionPolicy is invalid.");
228
243
  }
244
+ if (delegationLimits !== undefined &&
245
+ (!isPlainRecord(delegationLimits) ||
246
+ !hasOnlyKeys(delegationLimits, ["maxDepth", "maxChildrenPerAgent", "maxNestedAgentsPerSession"]) ||
247
+ !Number.isSafeInteger(delegationLimits.maxDepth) ||
248
+ !Number.isSafeInteger(delegationLimits.maxChildrenPerAgent) ||
249
+ (delegationLimits.maxNestedAgentsPerSession !== undefined &&
250
+ !Number.isSafeInteger(delegationLimits.maxNestedAgentsPerSession)))) {
251
+ throw new OrchestrationProfileError("Orchestration profile delegationLimits are invalid.");
252
+ }
229
253
  const candidates = modelPolicy.candidates.map((candidate) => {
230
254
  if (!isPlainRecord(candidate) || !hasOnlyKeys(candidate, ["provider", "modelId", "thinkingLevel"])) {
231
255
  throw new OrchestrationProfileError("Orchestration profile model candidate is invalid.");
@@ -297,6 +321,17 @@ export function parseOrchestrationProfile(value, sourcePath) {
297
321
  },
298
322
  }
299
323
  : {}),
324
+ ...(isPlainRecord(delegationLimits)
325
+ ? {
326
+ delegationLimits: {
327
+ maxDepth: Number(delegationLimits.maxDepth),
328
+ maxChildrenPerAgent: Number(delegationLimits.maxChildrenPerAgent),
329
+ ...(delegationLimits.maxNestedAgentsPerSession !== undefined
330
+ ? { maxNestedAgentsPerSession: Number(delegationLimits.maxNestedAgentsPerSession) }
331
+ : {}),
332
+ },
333
+ }
334
+ : {}),
300
335
  budget,
301
336
  maxConcurrent: Number(value.maxConcurrent),
302
337
  leaseTtlMs: Number(value.leaseTtlMs),
@@ -326,6 +361,8 @@ function freezeProfile(profile) {
326
361
  Object.freeze(clone.executionPolicy.allowedEnvironmentVariables);
327
362
  Object.freeze(clone.executionPolicy);
328
363
  }
364
+ if (clone.delegationLimits)
365
+ Object.freeze(clone.delegationLimits);
329
366
  Object.freeze(clone.budget);
330
367
  return Object.freeze(clone);
331
368
  }
@@ -1 +1 @@
1
- {"version":3,"file":"profile-registry.js","sourceRoot":"","sources":["../../../src/core/orchestration/profile-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC7G,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAWrE,OAAO,EACN,oBAAoB,EACpB,mCAAmC,EACnC,oCAAoC,EACpC,8CAA8C,EAC9C,mCAAmC,EACnC,iCAAiC,EACjC,uCAAuC,EACvC,sCAAsC,EACtC,gCAAgC,EAChC,4BAA4B,EAC5B,6BAA6B,EAC7B,YAAY,EACZ,YAAY,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gCAAgC,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAEN,gCAAgC,GAGhC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAkBvE,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IACnD,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IACzC,CAAC;CACD;AAED,SAAS,gBAAgB,CAAC,MAAyB;IAClD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC5B,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,UAAU,CAAC,GAAG,CAAC,KAAK,CAA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AC;IAC1D,IAAI,QAAQ,CAAC,OAAO,KAAK,OAAO;QAAE,OAAO,QAAQ,CAAC;IAClD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC;AACrH,CAAC","sourcesContent":["import { describeToolCapabilityAuthority, resolveProfileToolCapability } from \"../tool-capability-policy.ts\";\nimport { hasOnlyKeys, isPlainRecord } from \"../util/value-guards.ts\";\nimport type {\n\tExecutionGrant,\n\tOrchestrationDispatchRequest,\n\tOrchestrationModelBinding,\n\tOrchestrationProfile,\n\tResourcePointer,\n\tRiskBudget,\n\tTaskContract,\n\tToolCapabilityManifest,\n} from \"./contracts.ts\";\nimport {\n\tHARNESS_CAPABILITIES,\n\tMAX_ORCHESTRATION_COLLECTION_LENGTH,\n\tMAX_ORCHESTRATION_DESCRIPTION_LENGTH,\n\tMAX_ORCHESTRATION_DISPATCH_INSTRUCTIONS_LENGTH,\n\tMAX_ORCHESTRATION_IDENTIFIER_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_ID_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH,\n\tMAX_ORCHESTRATION_PROCESS_OUTPUT_BYTES,\n\tMAX_WORKER_AUTHORITY_PATH_LENGTH,\n\tORCHESTRATION_SCHEMA_VERSION,\n\tORCHESTRATION_THINKING_LEVELS,\n\ttoJsonObject,\n\tWORKER_ROLES,\n} from \"./contracts.ts\";\nimport { ORCHESTRATION_PROFILE_TOOL_NAMES } from \"./lane-tool-manifests.ts\";\nimport {\n\ttype CompileExecutionGrantInput,\n\tDEFAULT_ROLE_CAPABILITY_CEILINGS,\n\ttype ExecutionPolicyCompiler,\n\ttype PolicyCompilationResult,\n} from \"./policy-compiler.ts\";\nimport { parseRiskBudget, validateRiskBudget } from \"./risk-budget.ts\";\n\nexport interface ModelHealthView {\n\tisHealthy(binding: OrchestrationModelBinding): boolean;\n}\n\nexport interface ProfileDispatchPlan {\n\tprofile: OrchestrationProfile;\n\tmodel: OrchestrationModelBinding;\n\tgrant: ExecutionGrant;\n\ttoolManifests: readonly ToolCapabilityManifest[];\n}\n\nexport type ProfileDispatchPlanResult =\n\t| { outcome: \"allow\"; plan: ProfileDispatchPlan }\n\t| Exclude<PolicyCompilationResult, { outcome: \"allow\" }>\n\t| { outcome: \"deny\"; decisions: readonly []; reasonCodes: readonly [\"profile_model_unavailable\"] };\n\nexport class OrchestrationProfileError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"OrchestrationProfileError\";\n\t}\n}\n\nfunction duplicateStrings(values: readonly string[]): string[] {\n\tconst seen = new Set<string>();\n\tconst duplicates = new Set<string>();\n\tfor (const value of values) {\n\t\tif (seen.has(value)) duplicates.add(value);\n\t\tseen.add(value);\n\t}\n\treturn [...duplicates];\n}\n\nexport function parseOrchestrationDispatchRequest(value: unknown): OrchestrationDispatchRequest {\n\tif (!isPlainRecord(value)) throw new OrchestrationProfileError(\"Dispatch request must be an object.\");\n\tif (!hasOnlyKeys(value, [\"taskId\", \"profileId\", \"instructions\", \"resourcePointerIds\"])) {\n\t\tthrow new OrchestrationProfileError(\"Dispatch request contains an unsupported durable metadata field.\");\n\t}\n\tif (\n\t\ttypeof value.taskId !== \"string\" ||\n\t\t!value.taskId ||\n\t\tvalue.taskId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.profileId !== \"string\" ||\n\t\t!value.profileId ||\n\t\tvalue.profileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.instructions !== \"string\" ||\n\t\tvalue.instructions.length > MAX_ORCHESTRATION_DISPATCH_INSTRUCTIONS_LENGTH ||\n\t\t!value.instructions.trim() ||\n\t\t!Array.isArray(value.resourcePointerIds) ||\n\t\tvalue.resourcePointerIds.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t!value.resourcePointerIds.every(\n\t\t\t(entry) =>\n\t\t\t\ttypeof entry === \"string\" && entry.length > 0 && entry.length <= MAX_ORCHESTRATION_IDENTIFIER_LENGTH,\n\t\t) ||\n\t\tnew Set(value.resourcePointerIds).size !== value.resourcePointerIds.length\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Dispatch request is invalid.\");\n\t}\n\treturn {\n\t\ttaskId: value.taskId,\n\t\tprofileId: value.profileId,\n\t\tinstructions: value.instructions.trim(),\n\t\tresourcePointerIds: [...value.resourcePointerIds],\n\t};\n}\n\nexport function validateOrchestrationProfile(profile: OrchestrationProfile): void {\n\tif (profile.schemaVersion !== ORCHESTRATION_SCHEMA_VERSION) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' has an unsupported schema version.`);\n\t}\n\tif (\n\t\tprofile.profileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\t!profile.profileId.trim() ||\n\t\tprofile.description.length > MAX_ORCHESTRATION_DESCRIPTION_LENGTH ||\n\t\t!profile.description.trim()\n\t)\n\t\tthrow new OrchestrationProfileError(\"Profile id and description are required.\");\n\tif (profile.role !== \"orchestrator\" && profile.dispatchProfileIds.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Only orchestrator profiles may declare dispatchProfileIds ('${profile.profileId}').`,\n\t\t);\n\t}\n\tif (profile.dispatchProfileIds.includes(profile.profileId)) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' cannot dispatch itself.`);\n\t}\n\tif (profile.requireIndependentVerification) {\n\t\tif (profile.role === \"verifier\") {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Verifier profile '${profile.profileId}' cannot require another verifier.`,\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\t!profile.verificationProfileId?.trim() ||\n\t\t\tprofile.verificationProfileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Profile '${profile.profileId}' requires independent verification but has no verificationProfileId.`,\n\t\t\t);\n\t\t}\n\t} else if (profile.verificationProfileId !== undefined) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' cannot declare verificationProfileId without requiring verification.`,\n\t\t);\n\t}\n\tif (profile.verificationProfileId === profile.profileId) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' cannot verify itself.`);\n\t}\n\tif (\n\t\t!profile.createdAt.trim() ||\n\t\tprofile.createdAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\t!profile.updatedAt.trim() ||\n\t\tprofile.updatedAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' timestamps are invalid.`);\n\t}\n\tfor (const [label, values] of [\n\t\t[\"capabilityCeiling\", profile.capabilityCeiling],\n\t\t[\"toolNames\", profile.toolNames],\n\t\t[\"resourceProfileNames\", profile.resourceProfileNames],\n\t\t[\"dispatchProfileIds\", profile.dispatchProfileIds],\n\t] as const) {\n\t\tif (\n\t\t\tvalues.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t\tvalues.some((value) => !value.trim() || value.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH)\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' contains an invalid ${label}.`);\n\t\t}\n\t\tconst duplicates = duplicateStrings(values);\n\t\tif (duplicates.length > 0) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Profile '${profile.profileId}' contains duplicate ${label}: ${duplicates.join(\", \")}.`,\n\t\t\t);\n\t\t}\n\t}\n\tconst roleCeiling = new Set(DEFAULT_ROLE_CAPABILITY_CEILINGS[profile.role]);\n\tconst outOfRoleCapabilities = profile.capabilityCeiling.filter((capability) => !roleCeiling.has(capability));\n\tif (outOfRoleCapabilities.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' exceeds the ${profile.role} role ceiling: ${outOfRoleCapabilities.join(\", \")}.`,\n\t\t);\n\t}\n\tif (\n\t\tprofile.modelPolicy.candidates.length === 0 ||\n\t\tprofile.modelPolicy.candidates.length > MAX_ORCHESTRATION_COLLECTION_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' must declare a model candidate.`);\n\t}\n\tif (profile.modelPolicy.mode === \"fixed\" && profile.modelPolicy.candidates.length !== 1) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Fixed profile '${profile.profileId}' must declare exactly one model candidate.`,\n\t\t);\n\t}\n\tfor (const candidate of profile.modelPolicy.candidates) {\n\t\tif (\n\t\t\tcandidate.provider.length > MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH ||\n\t\t\t!candidate.provider.trim() ||\n\t\t\tcandidate.modelId.length > MAX_ORCHESTRATION_MODEL_ID_LENGTH ||\n\t\t\t!candidate.modelId.trim()\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' contains an invalid model binding.`);\n\t\t}\n\t}\n\tconst duplicateModels = duplicateStrings(\n\t\tprofile.modelPolicy.candidates.map((candidate) => `${candidate.provider}/${candidate.modelId}`),\n\t);\n\tif (duplicateModels.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' contains duplicate model candidates: ${duplicateModels.join(\", \")}.`,\n\t\t);\n\t}\n\tif (!Number.isSafeInteger(profile.maxConcurrent) || profile.maxConcurrent <= 0) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' maxConcurrent must be positive.`);\n\t}\n\tif (!Number.isSafeInteger(profile.leaseTtlMs) || profile.leaseTtlMs <= 0) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' leaseTtlMs must be positive.`);\n\t}\n\ttry {\n\t\tvalidateRiskBudget(profile.budget, `Profile '${profile.profileId}' budget`);\n\t} catch (error) {\n\t\tthrow new OrchestrationProfileError(error instanceof Error ? error.message : String(error));\n\t}\n\tif (profile.budget.maxWallClockMs !== undefined && profile.budget.maxWallClockMs <= 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' maxWallClockMs budget must be positive when specified.`,\n\t\t);\n\t}\n\tif (profile.budget.maxWallClockMs !== undefined && profile.leaseTtlMs < profile.budget.maxWallClockMs) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' leaseTtlMs must cover its maxWallClockMs budget.`,\n\t\t);\n\t}\n\tconst processCapable =\n\t\tprofile.capabilityCeiling.includes(\"process.exec\") || profile.capabilityCeiling.includes(\"tests.execute\");\n\tconst directProcessLauncher = profile.toolNames.includes(\"run_process\");\n\tif (directProcessLauncher && (!profile.executionPolicy || profile.executionPolicy.allowedExecutables.length === 0)) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' must declare executionPolicy.allowedExecutables for run_process.`,\n\t\t);\n\t}\n\tif (!processCapable && profile.executionPolicy) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' cannot declare executionPolicy without process capabilities.`,\n\t\t);\n\t}\n\tif (profile.executionPolicy) {\n\t\tif (\n\t\t\tprofile.executionPolicy.allowedExecutables.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t\tprofile.executionPolicy.allowedEnvironmentVariables.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t\tprofile.executionPolicy.allowedExecutables.some(\n\t\t\t\t(executable) =>\n\t\t\t\t\t!executable.trim() ||\n\t\t\t\t\texecutable.length > MAX_WORKER_AUTHORITY_PATH_LENGTH ||\n\t\t\t\t\t/[\\0\\r\\n]/.test(executable),\n\t\t\t) ||\n\t\t\tprofile.executionPolicy.allowedEnvironmentVariables.some(\n\t\t\t\t(name) => name.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(name),\n\t\t\t) ||\n\t\t\t!Number.isSafeInteger(profile.executionPolicy.maxOutputBytes) ||\n\t\t\tprofile.executionPolicy.maxOutputBytes <= 0 ||\n\t\t\tprofile.executionPolicy.maxOutputBytes > MAX_ORCHESTRATION_PROCESS_OUTPUT_BYTES\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' executionPolicy is invalid.`);\n\t\t}\n\t}\n\tconst unknownTools = profile.toolNames.filter(\n\t\t(toolName) => !(ORCHESTRATION_PROFILE_TOOL_NAMES as readonly string[]).includes(toolName),\n\t);\n\tif (unknownTools.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' contains unclassified orchestration tools: ${unknownTools.join(\", \")}.`,\n\t\t);\n\t}\n\tfor (const toolName of profile.toolNames) {\n\t\tif (!resolveProfileToolCapability(profile, toolName)) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Profile '${profile.profileId}' tool '${toolName}' lacks ${describeToolCapabilityAuthority(toolName)} authority.`,\n\t\t\t);\n\t\t}\n\t}\n\ttoJsonObject({ profile });\n}\n\nfunction isStringArray(value: unknown, maxLength = MAX_ORCHESTRATION_IDENTIFIER_LENGTH): value is string[] {\n\treturn (\n\t\tArray.isArray(value) &&\n\t\tvalue.length <= MAX_ORCHESTRATION_COLLECTION_LENGTH &&\n\t\tvalue.every((entry) => typeof entry === \"string\" && entry.length > 0 && entry.length <= maxLength)\n\t);\n}\n\nexport function parseOrchestrationProfile(value: unknown, sourcePath?: string): OrchestrationProfile {\n\tif (!isPlainRecord(value)) throw new OrchestrationProfileError(\"Orchestration profile must be an object.\");\n\tif (\n\t\t!hasOnlyKeys(value, [\n\t\t\t\"schemaVersion\",\n\t\t\t\"profileId\",\n\t\t\t\"description\",\n\t\t\t\"role\",\n\t\t\t\"modelPolicy\",\n\t\t\t\"capabilityCeiling\",\n\t\t\t\"toolNames\",\n\t\t\t\"resourceProfileNames\",\n\t\t\t\"dispatchProfileIds\",\n\t\t\t\"executionPolicy\",\n\t\t\t\"budget\",\n\t\t\t\"maxConcurrent\",\n\t\t\t\"leaseTtlMs\",\n\t\t\t\"requireIndependentVerification\",\n\t\t\t\"verificationProfileId\",\n\t\t\t\"createdAt\",\n\t\t\t\"updatedAt\",\n\t\t])\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile contains an unsupported field.\");\n\t}\n\tconst modelPolicy = value.modelPolicy;\n\tconst rawBudget = value.budget;\n\tlet budget: RiskBudget;\n\tconst executionPolicy = value.executionPolicy;\n\tif (\n\t\t!isPlainRecord(modelPolicy) ||\n\t\t!hasOnlyKeys(modelPolicy, [\"mode\", \"candidates\"]) ||\n\t\t!Array.isArray(modelPolicy.candidates) ||\n\t\tmodelPolicy.candidates.length > MAX_ORCHESTRATION_COLLECTION_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile modelPolicy is invalid.\");\n\t}\n\ttry {\n\t\tbudget = parseRiskBudget(rawBudget, \"Orchestration profile budget\");\n\t} catch (error) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\terror instanceof Error ? error.message : \"Orchestration profile budget is invalid.\",\n\t\t);\n\t}\n\tif (\n\t\texecutionPolicy !== undefined &&\n\t\t(!isPlainRecord(executionPolicy) ||\n\t\t\t!hasOnlyKeys(executionPolicy, [\"allowedExecutables\", \"allowedEnvironmentVariables\", \"maxOutputBytes\"]) ||\n\t\t\t!isStringArray(executionPolicy.allowedExecutables, MAX_WORKER_AUTHORITY_PATH_LENGTH) ||\n\t\t\t!isStringArray(executionPolicy.allowedEnvironmentVariables) ||\n\t\t\t!Number.isSafeInteger(executionPolicy.maxOutputBytes))\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile executionPolicy is invalid.\");\n\t}\n\tconst candidates = modelPolicy.candidates.map((candidate) => {\n\t\tif (!isPlainRecord(candidate) || !hasOnlyKeys(candidate, [\"provider\", \"modelId\", \"thinkingLevel\"])) {\n\t\t\tthrow new OrchestrationProfileError(\"Orchestration profile model candidate is invalid.\");\n\t\t}\n\t\tif (\n\t\t\ttypeof candidate.provider !== \"string\" ||\n\t\t\tcandidate.provider.length === 0 ||\n\t\t\tcandidate.provider.length > MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH ||\n\t\t\ttypeof candidate.modelId !== \"string\" ||\n\t\t\tcandidate.modelId.length === 0 ||\n\t\t\tcandidate.modelId.length > MAX_ORCHESTRATION_MODEL_ID_LENGTH ||\n\t\t\ttypeof candidate.thinkingLevel !== \"string\" ||\n\t\t\t!ORCHESTRATION_THINKING_LEVELS.includes(\n\t\t\t\tcandidate.thinkingLevel as (typeof ORCHESTRATION_THINKING_LEVELS)[number],\n\t\t\t)\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(\"Orchestration profile model candidate is invalid.\");\n\t\t}\n\t\treturn {\n\t\t\tprovider: candidate.provider,\n\t\t\tmodelId: candidate.modelId,\n\t\t\tthinkingLevel: candidate.thinkingLevel as (typeof ORCHESTRATION_THINKING_LEVELS)[number],\n\t\t};\n\t});\n\tif (\n\t\tvalue.schemaVersion !== ORCHESTRATION_SCHEMA_VERSION ||\n\t\ttypeof value.profileId !== \"string\" ||\n\t\tvalue.profileId.length === 0 ||\n\t\tvalue.profileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.description !== \"string\" ||\n\t\tvalue.description.length === 0 ||\n\t\tvalue.description.length > MAX_ORCHESTRATION_DESCRIPTION_LENGTH ||\n\t\ttypeof value.role !== \"string\" ||\n\t\t!WORKER_ROLES.includes(value.role as (typeof WORKER_ROLES)[number]) ||\n\t\t(modelPolicy.mode !== \"fixed\" && modelPolicy.mode !== \"ordered-fallback\") ||\n\t\t!Array.isArray(value.capabilityCeiling) ||\n\t\tvalue.capabilityCeiling.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t!value.capabilityCeiling.every(\n\t\t\t(capability) =>\n\t\t\t\ttypeof capability === \"string\" &&\n\t\t\t\tHARNESS_CAPABILITIES.includes(capability as (typeof HARNESS_CAPABILITIES)[number]),\n\t\t) ||\n\t\t!isStringArray(value.toolNames) ||\n\t\t!isStringArray(value.resourceProfileNames) ||\n\t\t!isStringArray(value.dispatchProfileIds) ||\n\t\t!Number.isSafeInteger(value.maxConcurrent) ||\n\t\t!Number.isSafeInteger(value.leaseTtlMs) ||\n\t\ttypeof value.requireIndependentVerification !== \"boolean\" ||\n\t\t(value.verificationProfileId !== undefined &&\n\t\t\t(typeof value.verificationProfileId !== \"string\" ||\n\t\t\t\tvalue.verificationProfileId.length === 0 ||\n\t\t\t\tvalue.verificationProfileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH)) ||\n\t\ttypeof value.createdAt !== \"string\" ||\n\t\tvalue.createdAt.length === 0 ||\n\t\tvalue.createdAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.updatedAt !== \"string\" ||\n\t\tvalue.updatedAt.length === 0 ||\n\t\tvalue.updatedAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile is invalid.\");\n\t}\n\tconst profile = structuredClone({\n\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\tprofileId: value.profileId,\n\t\tdescription: value.description,\n\t\trole: value.role as OrchestrationProfile[\"role\"],\n\t\tmodelPolicy: { mode: modelPolicy.mode as OrchestrationProfile[\"modelPolicy\"][\"mode\"], candidates },\n\t\tcapabilityCeiling: value.capabilityCeiling as OrchestrationProfile[\"capabilityCeiling\"],\n\t\ttoolNames: value.toolNames,\n\t\tresourceProfileNames: value.resourceProfileNames,\n\t\tdispatchProfileIds: value.dispatchProfileIds,\n\t\t...(executionPolicy\n\t\t\t? {\n\t\t\t\t\texecutionPolicy: {\n\t\t\t\t\t\tallowedExecutables: executionPolicy.allowedExecutables as string[],\n\t\t\t\t\t\tallowedEnvironmentVariables: executionPolicy.allowedEnvironmentVariables as string[],\n\t\t\t\t\t\tmaxOutputBytes: Number(executionPolicy.maxOutputBytes),\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t\tbudget,\n\t\tmaxConcurrent: Number(value.maxConcurrent),\n\t\tleaseTtlMs: Number(value.leaseTtlMs),\n\t\trequireIndependentVerification: value.requireIndependentVerification,\n\t\t...(typeof value.verificationProfileId === \"string\"\n\t\t\t? { verificationProfileId: value.verificationProfileId }\n\t\t\t: {}),\n\t\t...(sourcePath ? { sourcePath } : {}),\n\t\tcreatedAt: value.createdAt,\n\t\tupdatedAt: value.updatedAt,\n\t}) as OrchestrationProfile;\n\tvalidateOrchestrationProfile(profile);\n\treturn profile;\n}\n\nfunction freezeProfile(profile: OrchestrationProfile): OrchestrationProfile {\n\tconst clone = structuredClone(profile);\n\tfor (const candidate of clone.modelPolicy.candidates) Object.freeze(candidate);\n\tObject.freeze(clone.modelPolicy.candidates);\n\tObject.freeze(clone.modelPolicy);\n\tObject.freeze(clone.capabilityCeiling);\n\tObject.freeze(clone.toolNames);\n\tObject.freeze(clone.resourceProfileNames);\n\tObject.freeze(clone.dispatchProfileIds);\n\tif (clone.executionPolicy) {\n\t\tObject.freeze(clone.executionPolicy.allowedExecutables);\n\t\tObject.freeze(clone.executionPolicy.allowedEnvironmentVariables);\n\t\tObject.freeze(clone.executionPolicy);\n\t}\n\tObject.freeze(clone.budget);\n\treturn Object.freeze(clone);\n}\n\nexport class OrchestrationProfileRegistry {\n\tprivate readonly profiles = new Map<string, OrchestrationProfile>();\n\n\tconstructor(profiles: readonly OrchestrationProfile[] = []) {\n\t\tfor (const profile of profiles) this.register(profile);\n\t\tfor (const profile of this.profiles.values()) {\n\t\t\tfor (const dispatchedProfileId of profile.dispatchProfileIds) {\n\t\t\t\tconst target = this.profiles.get(dispatchedProfileId);\n\t\t\t\tif (!target) {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Profile '${profile.profileId}' dispatches missing profile '${dispatchedProfileId}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (profile.verificationProfileId) {\n\t\t\t\tconst verifier = this.profiles.get(profile.verificationProfileId);\n\t\t\t\tif (!verifier) {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Profile '${profile.profileId}' requires missing verifier profile '${profile.verificationProfileId}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (verifier.role !== \"verifier\") {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Profile '${profile.profileId}' verificationProfileId '${profile.verificationProfileId}' is not a verifier.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (profile.role === \"orchestrator\") {\n\t\t\t\tfor (const dispatchedProfileId of profile.dispatchProfileIds) {\n\t\t\t\t\tconst worker = this.profiles.get(dispatchedProfileId);\n\t\t\t\t\tif (\n\t\t\t\t\t\tworker?.verificationProfileId &&\n\t\t\t\t\t\t!profile.dispatchProfileIds.includes(worker.verificationProfileId)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t\t`Orchestrator '${profile.profileId}' dispatches '${worker.profileId}' but not its verifier '${worker.verificationProfileId}'.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tregister(profile: OrchestrationProfile): void {\n\t\tvalidateOrchestrationProfile(profile);\n\t\tif (this.profiles.has(profile.profileId)) {\n\t\t\tthrow new OrchestrationProfileError(`Duplicate orchestration profile '${profile.profileId}'.`);\n\t\t}\n\t\tthis.profiles.set(profile.profileId, freezeProfile(profile));\n\t}\n\n\tget(profileId: string): OrchestrationProfile | undefined {\n\t\tconst profile = this.profiles.get(profileId);\n\t\treturn profile ? structuredClone(profile) : undefined;\n\t}\n\n\tlist(): OrchestrationProfile[] {\n\t\treturn [...this.profiles.values()].map((profile) => structuredClone(profile));\n\t}\n}\n\nexport function resolveProfileModel(\n\tprofile: OrchestrationProfile,\n\thealth: ModelHealthView,\n): OrchestrationModelBinding | undefined {\n\tif (profile.modelPolicy.mode === \"fixed\") {\n\t\tconst fixed = profile.modelPolicy.candidates[0];\n\t\treturn fixed && health.isHealthy(fixed) ? structuredClone(fixed) : undefined;\n\t}\n\tconst selected = profile.modelPolicy.candidates.find((candidate) => health.isHealthy(candidate));\n\treturn selected ? structuredClone(selected) : undefined;\n}\n\nexport function planProfileDispatch(args: {\n\trequest: OrchestrationDispatchRequest;\n\ttask: TaskContract;\n\tattemptId: string;\n\tsubjectId: string;\n\tregistry: OrchestrationProfileRegistry;\n\thealth: ModelHealthView;\n\tpolicyCompiler: ExecutionPolicyCompiler;\n\ttoolManifests: readonly ToolCapabilityManifest[];\n\tresources: readonly ResourcePointer[];\n\treadPaths: readonly string[];\n\twritePaths?: readonly string[];\n\tdeniedPaths?: readonly string[];\n\tpolicyVersion: string;\n}): ProfileDispatchPlanResult {\n\tconst profile = args.registry.get(args.request.profileId);\n\tif (!profile) return { outcome: \"deny\", decisions: [], reasonCodes: [\"profile_model_unavailable\"] };\n\tif (profile.role !== args.task.role) {\n\t\treturn { outcome: \"deny\", decisions: [], reasonCodes: [\"required_capability_exceeds_role_ceiling\"] };\n\t}\n\tconst model = resolveProfileModel(profile, args.health);\n\tif (!model) return { outcome: \"deny\", decisions: [], reasonCodes: [\"profile_model_unavailable\"] };\n\tconst selectedResources = args.resources.filter((resource) => args.request.resourcePointerIds.includes(resource.id));\n\tconst manifestsByName = new Map(args.toolManifests.map((manifest) => [manifest.toolName, manifest]));\n\tconst requestedTools = profile.toolNames.filter((toolName) => {\n\t\tconst manifest = manifestsByName.get(toolName);\n\t\treturn manifest?.capabilities.every((capability) => args.task.requiredCapabilities.includes(capability)) === true;\n\t});\n\tconst policyInput: CompileExecutionGrantInput = {\n\t\tobjectiveId: args.task.objectiveId,\n\t\ttaskId: args.task.taskId,\n\t\tattemptId: args.attemptId,\n\t\tsubjectId: args.subjectId,\n\t\trole: profile.role,\n\t\trequiredCapabilities: args.task.requiredCapabilities,\n\t\trequestedCapabilities: args.task.requiredCapabilities,\n\t\tauthorityCapabilities: profile.capabilityCeiling,\n\t\trequestedTools,\n\t\ttoolManifests: args.toolManifests,\n\t\tresources: selectedResources,\n\t\treadPaths: args.readPaths,\n\t\twritePaths: args.writePaths,\n\t\tdeniedPaths: args.deniedPaths,\n\t\trequestedBudget: profile.budget,\n\t\tauthorityBudget: profile.budget,\n\t\tpolicyVersion: args.policyVersion,\n\t};\n\tconst compiled = args.policyCompiler.compile(policyInput);\n\tif (compiled.outcome !== \"allow\") return compiled;\n\treturn { outcome: \"allow\", plan: { profile, model, grant: compiled.grant, toolManifests: compiled.toolManifests } };\n}\n"]}
1
+ {"version":3,"file":"profile-registry.js","sourceRoot":"","sources":["../../../src/core/orchestration/profile-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC7G,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAWrE,OAAO,EACN,oBAAoB,EACpB,gCAAgC,EAChC,6BAA6B,EAC7B,mCAAmC,EACnC,oCAAoC,EACpC,iCAAiC,EACjC,8CAA8C,EAC9C,mCAAmC,EACnC,iCAAiC,EACjC,uCAAuC,EACvC,sCAAsC,EACtC,gCAAgC,EAChC,4BAA4B,EAC5B,6BAA6B,EAC7B,YAAY,EACZ,YAAY,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gCAAgC,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAEN,gCAAgC,GAGhC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAkBvE,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IACnD,YAAY,O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CAAC;AACrH,CAAC","sourcesContent":["import { describeToolCapabilityAuthority, resolveProfileToolCapability } from \"../tool-capability-policy.ts\";\nimport { hasOnlyKeys, isPlainRecord } from \"../util/value-guards.ts\";\nimport type {\n\tExecutionGrant,\n\tOrchestrationDispatchRequest,\n\tOrchestrationModelBinding,\n\tOrchestrationProfile,\n\tResourcePointer,\n\tRiskBudget,\n\tTaskContract,\n\tToolCapabilityManifest,\n} from \"./contracts.ts\";\nimport {\n\tHARNESS_CAPABILITIES,\n\tMAX_ORCHESTRATION_AGENT_BINDINGS,\n\tMAX_ORCHESTRATION_AGENT_DEPTH,\n\tMAX_ORCHESTRATION_COLLECTION_LENGTH,\n\tMAX_ORCHESTRATION_DESCRIPTION_LENGTH,\n\tMAX_ORCHESTRATION_DIRECT_CHILDREN,\n\tMAX_ORCHESTRATION_DISPATCH_INSTRUCTIONS_LENGTH,\n\tMAX_ORCHESTRATION_IDENTIFIER_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_ID_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH,\n\tMAX_ORCHESTRATION_PROCESS_OUTPUT_BYTES,\n\tMAX_WORKER_AUTHORITY_PATH_LENGTH,\n\tORCHESTRATION_SCHEMA_VERSION,\n\tORCHESTRATION_THINKING_LEVELS,\n\ttoJsonObject,\n\tWORKER_ROLES,\n} from \"./contracts.ts\";\nimport { ORCHESTRATION_PROFILE_TOOL_NAMES } from \"./lane-tool-manifests.ts\";\nimport {\n\ttype CompileExecutionGrantInput,\n\tDEFAULT_ROLE_CAPABILITY_CEILINGS,\n\ttype ExecutionPolicyCompiler,\n\ttype PolicyCompilationResult,\n} from \"./policy-compiler.ts\";\nimport { parseRiskBudget, validateRiskBudget } from \"./risk-budget.ts\";\n\nexport interface ModelHealthView {\n\tisHealthy(binding: OrchestrationModelBinding): boolean;\n}\n\nexport interface ProfileDispatchPlan {\n\tprofile: OrchestrationProfile;\n\tmodel: OrchestrationModelBinding;\n\tgrant: ExecutionGrant;\n\ttoolManifests: readonly ToolCapabilityManifest[];\n}\n\nexport type ProfileDispatchPlanResult =\n\t| { outcome: \"allow\"; plan: ProfileDispatchPlan }\n\t| Exclude<PolicyCompilationResult, { outcome: \"allow\" }>\n\t| { outcome: \"deny\"; decisions: readonly []; reasonCodes: readonly [\"profile_model_unavailable\"] };\n\nexport class OrchestrationProfileError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"OrchestrationProfileError\";\n\t}\n}\n\nfunction duplicateStrings(values: readonly string[]): string[] {\n\tconst seen = new Set<string>();\n\tconst duplicates = new Set<string>();\n\tfor (const value of values) {\n\t\tif (seen.has(value)) duplicates.add(value);\n\t\tseen.add(value);\n\t}\n\treturn [...duplicates];\n}\n\nexport function parseOrchestrationDispatchRequest(value: unknown): OrchestrationDispatchRequest {\n\tif (!isPlainRecord(value)) throw new OrchestrationProfileError(\"Dispatch request must be an object.\");\n\tif (!hasOnlyKeys(value, [\"taskId\", \"profileId\", \"instructions\", \"resourcePointerIds\"])) {\n\t\tthrow new OrchestrationProfileError(\"Dispatch request contains an unsupported durable metadata field.\");\n\t}\n\tif (\n\t\ttypeof value.taskId !== \"string\" ||\n\t\t!value.taskId ||\n\t\tvalue.taskId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.profileId !== \"string\" ||\n\t\t!value.profileId ||\n\t\tvalue.profileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.instructions !== \"string\" ||\n\t\tvalue.instructions.length > MAX_ORCHESTRATION_DISPATCH_INSTRUCTIONS_LENGTH ||\n\t\t!value.instructions.trim() ||\n\t\t!Array.isArray(value.resourcePointerIds) ||\n\t\tvalue.resourcePointerIds.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t!value.resourcePointerIds.every(\n\t\t\t(entry) =>\n\t\t\t\ttypeof entry === \"string\" && entry.length > 0 && entry.length <= MAX_ORCHESTRATION_IDENTIFIER_LENGTH,\n\t\t) ||\n\t\tnew Set(value.resourcePointerIds).size !== value.resourcePointerIds.length\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Dispatch request is invalid.\");\n\t}\n\treturn {\n\t\ttaskId: value.taskId,\n\t\tprofileId: value.profileId,\n\t\tinstructions: value.instructions.trim(),\n\t\tresourcePointerIds: [...value.resourcePointerIds],\n\t};\n}\n\nexport function validateOrchestrationProfile(profile: OrchestrationProfile): void {\n\tif (profile.schemaVersion !== ORCHESTRATION_SCHEMA_VERSION) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' has an unsupported schema version.`);\n\t}\n\tif (\n\t\tprofile.profileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\t!profile.profileId.trim() ||\n\t\tprofile.description.length > MAX_ORCHESTRATION_DESCRIPTION_LENGTH ||\n\t\t!profile.description.trim()\n\t)\n\t\tthrow new OrchestrationProfileError(\"Profile id and description are required.\");\n\tif (profile.role !== \"orchestrator\" && profile.dispatchProfileIds.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Only orchestrator profiles may declare dispatchProfileIds ('${profile.profileId}').`,\n\t\t);\n\t}\n\tif (profile.dispatchProfileIds.includes(profile.profileId)) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' cannot dispatch itself.`);\n\t}\n\tif (profile.requireIndependentVerification) {\n\t\tif (profile.role === \"verifier\") {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Verifier profile '${profile.profileId}' cannot require another verifier.`,\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\t!profile.verificationProfileId?.trim() ||\n\t\t\tprofile.verificationProfileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Profile '${profile.profileId}' requires independent verification but has no verificationProfileId.`,\n\t\t\t);\n\t\t}\n\t} else if (profile.verificationProfileId !== undefined) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' cannot declare verificationProfileId without requiring verification.`,\n\t\t);\n\t}\n\tif (profile.verificationProfileId === profile.profileId) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' cannot verify itself.`);\n\t}\n\tif (\n\t\t!profile.createdAt.trim() ||\n\t\tprofile.createdAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\t!profile.updatedAt.trim() ||\n\t\tprofile.updatedAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' timestamps are invalid.`);\n\t}\n\tfor (const [label, values] of [\n\t\t[\"capabilityCeiling\", profile.capabilityCeiling],\n\t\t[\"toolNames\", profile.toolNames],\n\t\t[\"resourceProfileNames\", profile.resourceProfileNames],\n\t\t[\"dispatchProfileIds\", profile.dispatchProfileIds],\n\t] as const) {\n\t\tif (\n\t\t\tvalues.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t\tvalues.some((value) => !value.trim() || value.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH)\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' contains an invalid ${label}.`);\n\t\t}\n\t\tconst duplicates = duplicateStrings(values);\n\t\tif (duplicates.length > 0) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Profile '${profile.profileId}' contains duplicate ${label}: ${duplicates.join(\", \")}.`,\n\t\t\t);\n\t\t}\n\t}\n\tconst roleCeiling = new Set(DEFAULT_ROLE_CAPABILITY_CEILINGS[profile.role]);\n\tconst outOfRoleCapabilities = profile.capabilityCeiling.filter((capability) => !roleCeiling.has(capability));\n\tif (outOfRoleCapabilities.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' exceeds the ${profile.role} role ceiling: ${outOfRoleCapabilities.join(\", \")}.`,\n\t\t);\n\t}\n\tif (\n\t\tprofile.modelPolicy.candidates.length === 0 ||\n\t\tprofile.modelPolicy.candidates.length > MAX_ORCHESTRATION_COLLECTION_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' must declare a model candidate.`);\n\t}\n\tif (profile.modelPolicy.mode === \"fixed\" && profile.modelPolicy.candidates.length !== 1) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Fixed profile '${profile.profileId}' must declare exactly one model candidate.`,\n\t\t);\n\t}\n\tfor (const candidate of profile.modelPolicy.candidates) {\n\t\tif (\n\t\t\tcandidate.provider.length > MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH ||\n\t\t\t!candidate.provider.trim() ||\n\t\t\tcandidate.modelId.length > MAX_ORCHESTRATION_MODEL_ID_LENGTH ||\n\t\t\t!candidate.modelId.trim()\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' contains an invalid model binding.`);\n\t\t}\n\t}\n\tconst duplicateModels = duplicateStrings(\n\t\tprofile.modelPolicy.candidates.map((candidate) => `${candidate.provider}/${candidate.modelId}`),\n\t);\n\tif (duplicateModels.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' contains duplicate model candidates: ${duplicateModels.join(\", \")}.`,\n\t\t);\n\t}\n\tif (!Number.isSafeInteger(profile.maxConcurrent) || profile.maxConcurrent <= 0) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' maxConcurrent must be positive.`);\n\t}\n\tif (!Number.isSafeInteger(profile.leaseTtlMs) || profile.leaseTtlMs <= 0) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' leaseTtlMs must be positive.`);\n\t}\n\tif (\n\t\tprofile.delegationLimits &&\n\t\t(!Number.isSafeInteger(profile.delegationLimits.maxDepth) ||\n\t\t\tprofile.delegationLimits.maxDepth < 0 ||\n\t\t\tprofile.delegationLimits.maxDepth > MAX_ORCHESTRATION_AGENT_DEPTH ||\n\t\t\t!Number.isSafeInteger(profile.delegationLimits.maxChildrenPerAgent) ||\n\t\t\tprofile.delegationLimits.maxChildrenPerAgent < 0 ||\n\t\t\tprofile.delegationLimits.maxChildrenPerAgent > MAX_ORCHESTRATION_DIRECT_CHILDREN ||\n\t\t\t(profile.delegationLimits.maxNestedAgentsPerSession !== undefined &&\n\t\t\t\t(!Number.isSafeInteger(profile.delegationLimits.maxNestedAgentsPerSession) ||\n\t\t\t\t\tprofile.delegationLimits.maxNestedAgentsPerSession < 0 ||\n\t\t\t\t\tprofile.delegationLimits.maxNestedAgentsPerSession > MAX_ORCHESTRATION_AGENT_BINDINGS)))\n\t) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' delegationLimits are invalid.`);\n\t}\n\ttry {\n\t\tvalidateRiskBudget(profile.budget, `Profile '${profile.profileId}' budget`);\n\t} catch (error) {\n\t\tthrow new OrchestrationProfileError(error instanceof Error ? error.message : String(error));\n\t}\n\tif (profile.budget.maxWallClockMs !== undefined && profile.budget.maxWallClockMs <= 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' maxWallClockMs budget must be positive when specified.`,\n\t\t);\n\t}\n\tif (profile.budget.maxWallClockMs !== undefined && profile.leaseTtlMs < profile.budget.maxWallClockMs) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' leaseTtlMs must cover its maxWallClockMs budget.`,\n\t\t);\n\t}\n\tconst processCapable =\n\t\tprofile.capabilityCeiling.includes(\"process.exec\") || profile.capabilityCeiling.includes(\"tests.execute\");\n\tconst directProcessLauncher = profile.toolNames.includes(\"run_process\");\n\tif (directProcessLauncher && (!profile.executionPolicy || profile.executionPolicy.allowedExecutables.length === 0)) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' must declare executionPolicy.allowedExecutables for run_process.`,\n\t\t);\n\t}\n\tif (!processCapable && profile.executionPolicy) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' cannot declare executionPolicy without process capabilities.`,\n\t\t);\n\t}\n\tif (profile.executionPolicy) {\n\t\tif (\n\t\t\tprofile.executionPolicy.allowedExecutables.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t\tprofile.executionPolicy.allowedEnvironmentVariables.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t\tprofile.executionPolicy.allowedExecutables.some(\n\t\t\t\t(executable) =>\n\t\t\t\t\t!executable.trim() ||\n\t\t\t\t\texecutable.length > MAX_WORKER_AUTHORITY_PATH_LENGTH ||\n\t\t\t\t\t/[\\0\\r\\n]/.test(executable),\n\t\t\t) ||\n\t\t\tprofile.executionPolicy.allowedEnvironmentVariables.some(\n\t\t\t\t(name) => name.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(name),\n\t\t\t) ||\n\t\t\t!Number.isSafeInteger(profile.executionPolicy.maxOutputBytes) ||\n\t\t\tprofile.executionPolicy.maxOutputBytes <= 0 ||\n\t\t\tprofile.executionPolicy.maxOutputBytes > MAX_ORCHESTRATION_PROCESS_OUTPUT_BYTES\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' executionPolicy is invalid.`);\n\t\t}\n\t}\n\tconst unknownTools = profile.toolNames.filter(\n\t\t(toolName) => !(ORCHESTRATION_PROFILE_TOOL_NAMES as readonly string[]).includes(toolName),\n\t);\n\tif (unknownTools.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' contains unclassified orchestration tools: ${unknownTools.join(\", \")}.`,\n\t\t);\n\t}\n\tfor (const toolName of profile.toolNames) {\n\t\tif (!resolveProfileToolCapability(profile, toolName)) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Profile '${profile.profileId}' tool '${toolName}' lacks ${describeToolCapabilityAuthority(toolName)} authority.`,\n\t\t\t);\n\t\t}\n\t}\n\ttoJsonObject({ profile });\n}\n\nfunction isStringArray(value: unknown, maxLength = MAX_ORCHESTRATION_IDENTIFIER_LENGTH): value is string[] {\n\treturn (\n\t\tArray.isArray(value) &&\n\t\tvalue.length <= MAX_ORCHESTRATION_COLLECTION_LENGTH &&\n\t\tvalue.every((entry) => typeof entry === \"string\" && entry.length > 0 && entry.length <= maxLength)\n\t);\n}\n\nexport function parseOrchestrationProfile(value: unknown, sourcePath?: string): OrchestrationProfile {\n\tif (!isPlainRecord(value)) throw new OrchestrationProfileError(\"Orchestration profile must be an object.\");\n\tif (\n\t\t!hasOnlyKeys(value, [\n\t\t\t\"schemaVersion\",\n\t\t\t\"profileId\",\n\t\t\t\"description\",\n\t\t\t\"role\",\n\t\t\t\"modelPolicy\",\n\t\t\t\"capabilityCeiling\",\n\t\t\t\"toolNames\",\n\t\t\t\"resourceProfileNames\",\n\t\t\t\"dispatchProfileIds\",\n\t\t\t\"executionPolicy\",\n\t\t\t\"delegationLimits\",\n\t\t\t\"budget\",\n\t\t\t\"maxConcurrent\",\n\t\t\t\"leaseTtlMs\",\n\t\t\t\"requireIndependentVerification\",\n\t\t\t\"verificationProfileId\",\n\t\t\t\"createdAt\",\n\t\t\t\"updatedAt\",\n\t\t])\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile contains an unsupported field.\");\n\t}\n\tconst modelPolicy = value.modelPolicy;\n\tconst rawBudget = value.budget;\n\tlet budget: RiskBudget;\n\tconst executionPolicy = value.executionPolicy;\n\tconst delegationLimits = value.delegationLimits;\n\tif (\n\t\t!isPlainRecord(modelPolicy) ||\n\t\t!hasOnlyKeys(modelPolicy, [\"mode\", \"candidates\"]) ||\n\t\t!Array.isArray(modelPolicy.candidates) ||\n\t\tmodelPolicy.candidates.length > MAX_ORCHESTRATION_COLLECTION_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile modelPolicy is invalid.\");\n\t}\n\ttry {\n\t\tbudget = parseRiskBudget(rawBudget, \"Orchestration profile budget\");\n\t} catch (error) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\terror instanceof Error ? error.message : \"Orchestration profile budget is invalid.\",\n\t\t);\n\t}\n\tif (\n\t\texecutionPolicy !== undefined &&\n\t\t(!isPlainRecord(executionPolicy) ||\n\t\t\t!hasOnlyKeys(executionPolicy, [\"allowedExecutables\", \"allowedEnvironmentVariables\", \"maxOutputBytes\"]) ||\n\t\t\t!isStringArray(executionPolicy.allowedExecutables, MAX_WORKER_AUTHORITY_PATH_LENGTH) ||\n\t\t\t!isStringArray(executionPolicy.allowedEnvironmentVariables) ||\n\t\t\t!Number.isSafeInteger(executionPolicy.maxOutputBytes))\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile executionPolicy is invalid.\");\n\t}\n\tif (\n\t\tdelegationLimits !== undefined &&\n\t\t(!isPlainRecord(delegationLimits) ||\n\t\t\t!hasOnlyKeys(delegationLimits, [\"maxDepth\", \"maxChildrenPerAgent\", \"maxNestedAgentsPerSession\"]) ||\n\t\t\t!Number.isSafeInteger(delegationLimits.maxDepth) ||\n\t\t\t!Number.isSafeInteger(delegationLimits.maxChildrenPerAgent) ||\n\t\t\t(delegationLimits.maxNestedAgentsPerSession !== undefined &&\n\t\t\t\t!Number.isSafeInteger(delegationLimits.maxNestedAgentsPerSession)))\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile delegationLimits are invalid.\");\n\t}\n\tconst candidates = modelPolicy.candidates.map((candidate) => {\n\t\tif (!isPlainRecord(candidate) || !hasOnlyKeys(candidate, [\"provider\", \"modelId\", \"thinkingLevel\"])) {\n\t\t\tthrow new OrchestrationProfileError(\"Orchestration profile model candidate is invalid.\");\n\t\t}\n\t\tif (\n\t\t\ttypeof candidate.provider !== \"string\" ||\n\t\t\tcandidate.provider.length === 0 ||\n\t\t\tcandidate.provider.length > MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH ||\n\t\t\ttypeof candidate.modelId !== \"string\" ||\n\t\t\tcandidate.modelId.length === 0 ||\n\t\t\tcandidate.modelId.length > MAX_ORCHESTRATION_MODEL_ID_LENGTH ||\n\t\t\ttypeof candidate.thinkingLevel !== \"string\" ||\n\t\t\t!ORCHESTRATION_THINKING_LEVELS.includes(\n\t\t\t\tcandidate.thinkingLevel as (typeof ORCHESTRATION_THINKING_LEVELS)[number],\n\t\t\t)\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(\"Orchestration profile model candidate is invalid.\");\n\t\t}\n\t\treturn {\n\t\t\tprovider: candidate.provider,\n\t\t\tmodelId: candidate.modelId,\n\t\t\tthinkingLevel: candidate.thinkingLevel as (typeof ORCHESTRATION_THINKING_LEVELS)[number],\n\t\t};\n\t});\n\tif (\n\t\tvalue.schemaVersion !== ORCHESTRATION_SCHEMA_VERSION ||\n\t\ttypeof value.profileId !== \"string\" ||\n\t\tvalue.profileId.length === 0 ||\n\t\tvalue.profileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.description !== \"string\" ||\n\t\tvalue.description.length === 0 ||\n\t\tvalue.description.length > MAX_ORCHESTRATION_DESCRIPTION_LENGTH ||\n\t\ttypeof value.role !== \"string\" ||\n\t\t!WORKER_ROLES.includes(value.role as (typeof WORKER_ROLES)[number]) ||\n\t\t(modelPolicy.mode !== \"fixed\" && modelPolicy.mode !== \"ordered-fallback\") ||\n\t\t!Array.isArray(value.capabilityCeiling) ||\n\t\tvalue.capabilityCeiling.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t!value.capabilityCeiling.every(\n\t\t\t(capability) =>\n\t\t\t\ttypeof capability === \"string\" &&\n\t\t\t\tHARNESS_CAPABILITIES.includes(capability as (typeof HARNESS_CAPABILITIES)[number]),\n\t\t) ||\n\t\t!isStringArray(value.toolNames) ||\n\t\t!isStringArray(value.resourceProfileNames) ||\n\t\t!isStringArray(value.dispatchProfileIds) ||\n\t\t!Number.isSafeInteger(value.maxConcurrent) ||\n\t\t!Number.isSafeInteger(value.leaseTtlMs) ||\n\t\ttypeof value.requireIndependentVerification !== \"boolean\" ||\n\t\t(value.verificationProfileId !== undefined &&\n\t\t\t(typeof value.verificationProfileId !== \"string\" ||\n\t\t\t\tvalue.verificationProfileId.length === 0 ||\n\t\t\t\tvalue.verificationProfileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH)) ||\n\t\ttypeof value.createdAt !== \"string\" ||\n\t\tvalue.createdAt.length === 0 ||\n\t\tvalue.createdAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.updatedAt !== \"string\" ||\n\t\tvalue.updatedAt.length === 0 ||\n\t\tvalue.updatedAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile is invalid.\");\n\t}\n\tconst profile = structuredClone({\n\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\tprofileId: value.profileId,\n\t\tdescription: value.description,\n\t\trole: value.role as OrchestrationProfile[\"role\"],\n\t\tmodelPolicy: { mode: modelPolicy.mode as OrchestrationProfile[\"modelPolicy\"][\"mode\"], candidates },\n\t\tcapabilityCeiling: value.capabilityCeiling as OrchestrationProfile[\"capabilityCeiling\"],\n\t\ttoolNames: value.toolNames,\n\t\tresourceProfileNames: value.resourceProfileNames,\n\t\tdispatchProfileIds: value.dispatchProfileIds,\n\t\t...(executionPolicy\n\t\t\t? {\n\t\t\t\t\texecutionPolicy: {\n\t\t\t\t\t\tallowedExecutables: executionPolicy.allowedExecutables as string[],\n\t\t\t\t\t\tallowedEnvironmentVariables: executionPolicy.allowedEnvironmentVariables as string[],\n\t\t\t\t\t\tmaxOutputBytes: Number(executionPolicy.maxOutputBytes),\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t\t...(isPlainRecord(delegationLimits)\n\t\t\t? {\n\t\t\t\t\tdelegationLimits: {\n\t\t\t\t\t\tmaxDepth: Number(delegationLimits.maxDepth),\n\t\t\t\t\t\tmaxChildrenPerAgent: Number(delegationLimits.maxChildrenPerAgent),\n\t\t\t\t\t\t...(delegationLimits.maxNestedAgentsPerSession !== undefined\n\t\t\t\t\t\t\t? { maxNestedAgentsPerSession: Number(delegationLimits.maxNestedAgentsPerSession) }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t\tbudget,\n\t\tmaxConcurrent: Number(value.maxConcurrent),\n\t\tleaseTtlMs: Number(value.leaseTtlMs),\n\t\trequireIndependentVerification: value.requireIndependentVerification,\n\t\t...(typeof value.verificationProfileId === \"string\"\n\t\t\t? { verificationProfileId: value.verificationProfileId }\n\t\t\t: {}),\n\t\t...(sourcePath ? { sourcePath } : {}),\n\t\tcreatedAt: value.createdAt,\n\t\tupdatedAt: value.updatedAt,\n\t}) as OrchestrationProfile;\n\tvalidateOrchestrationProfile(profile);\n\treturn profile;\n}\n\nfunction freezeProfile(profile: OrchestrationProfile): OrchestrationProfile {\n\tconst clone = structuredClone(profile);\n\tfor (const candidate of clone.modelPolicy.candidates) Object.freeze(candidate);\n\tObject.freeze(clone.modelPolicy.candidates);\n\tObject.freeze(clone.modelPolicy);\n\tObject.freeze(clone.capabilityCeiling);\n\tObject.freeze(clone.toolNames);\n\tObject.freeze(clone.resourceProfileNames);\n\tObject.freeze(clone.dispatchProfileIds);\n\tif (clone.executionPolicy) {\n\t\tObject.freeze(clone.executionPolicy.allowedExecutables);\n\t\tObject.freeze(clone.executionPolicy.allowedEnvironmentVariables);\n\t\tObject.freeze(clone.executionPolicy);\n\t}\n\tif (clone.delegationLimits) Object.freeze(clone.delegationLimits);\n\tObject.freeze(clone.budget);\n\treturn Object.freeze(clone);\n}\n\nexport class OrchestrationProfileRegistry {\n\tprivate readonly profiles = new Map<string, OrchestrationProfile>();\n\n\tconstructor(profiles: readonly OrchestrationProfile[] = []) {\n\t\tfor (const profile of profiles) this.register(profile);\n\t\tfor (const profile of this.profiles.values()) {\n\t\t\tfor (const dispatchedProfileId of profile.dispatchProfileIds) {\n\t\t\t\tconst target = this.profiles.get(dispatchedProfileId);\n\t\t\t\tif (!target) {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Profile '${profile.profileId}' dispatches missing profile '${dispatchedProfileId}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (profile.verificationProfileId) {\n\t\t\t\tconst verifier = this.profiles.get(profile.verificationProfileId);\n\t\t\t\tif (!verifier) {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Profile '${profile.profileId}' requires missing verifier profile '${profile.verificationProfileId}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (verifier.role !== \"verifier\") {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Profile '${profile.profileId}' verificationProfileId '${profile.verificationProfileId}' is not a verifier.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (profile.role === \"orchestrator\") {\n\t\t\t\tfor (const dispatchedProfileId of profile.dispatchProfileIds) {\n\t\t\t\t\tconst worker = this.profiles.get(dispatchedProfileId);\n\t\t\t\t\tif (\n\t\t\t\t\t\tworker?.verificationProfileId &&\n\t\t\t\t\t\t!profile.dispatchProfileIds.includes(worker.verificationProfileId)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t\t`Orchestrator '${profile.profileId}' dispatches '${worker.profileId}' but not its verifier '${worker.verificationProfileId}'.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tregister(profile: OrchestrationProfile): void {\n\t\tvalidateOrchestrationProfile(profile);\n\t\tif (this.profiles.has(profile.profileId)) {\n\t\t\tthrow new OrchestrationProfileError(`Duplicate orchestration profile '${profile.profileId}'.`);\n\t\t}\n\t\tthis.profiles.set(profile.profileId, freezeProfile(profile));\n\t}\n\n\tget(profileId: string): OrchestrationProfile | undefined {\n\t\tconst profile = this.profiles.get(profileId);\n\t\treturn profile ? structuredClone(profile) : undefined;\n\t}\n\n\tlist(): OrchestrationProfile[] {\n\t\treturn [...this.profiles.values()].map((profile) => structuredClone(profile));\n\t}\n}\n\nexport function resolveProfileModel(\n\tprofile: OrchestrationProfile,\n\thealth: ModelHealthView,\n): OrchestrationModelBinding | undefined {\n\tif (profile.modelPolicy.mode === \"fixed\") {\n\t\tconst fixed = profile.modelPolicy.candidates[0];\n\t\treturn fixed && health.isHealthy(fixed) ? structuredClone(fixed) : undefined;\n\t}\n\tconst selected = profile.modelPolicy.candidates.find((candidate) => health.isHealthy(candidate));\n\treturn selected ? structuredClone(selected) : undefined;\n}\n\nexport function planProfileDispatch(args: {\n\trequest: OrchestrationDispatchRequest;\n\ttask: TaskContract;\n\tattemptId: string;\n\tsubjectId: string;\n\tregistry: OrchestrationProfileRegistry;\n\thealth: ModelHealthView;\n\tpolicyCompiler: ExecutionPolicyCompiler;\n\ttoolManifests: readonly ToolCapabilityManifest[];\n\tresources: readonly ResourcePointer[];\n\treadPaths: readonly string[];\n\twritePaths?: readonly string[];\n\tdeniedPaths?: readonly string[];\n\tpolicyVersion: string;\n}): ProfileDispatchPlanResult {\n\tconst profile = args.registry.get(args.request.profileId);\n\tif (!profile) return { outcome: \"deny\", decisions: [], reasonCodes: [\"profile_model_unavailable\"] };\n\tif (profile.role !== args.task.role) {\n\t\treturn { outcome: \"deny\", decisions: [], reasonCodes: [\"required_capability_exceeds_role_ceiling\"] };\n\t}\n\tconst model = resolveProfileModel(profile, args.health);\n\tif (!model) return { outcome: \"deny\", decisions: [], reasonCodes: [\"profile_model_unavailable\"] };\n\tconst selectedResources = args.resources.filter((resource) => args.request.resourcePointerIds.includes(resource.id));\n\tconst manifestsByName = new Map(args.toolManifests.map((manifest) => [manifest.toolName, manifest]));\n\tconst requestedTools = profile.toolNames.filter((toolName) => {\n\t\tconst manifest = manifestsByName.get(toolName);\n\t\treturn manifest?.capabilities.every((capability) => args.task.requiredCapabilities.includes(capability)) === true;\n\t});\n\tconst policyInput: CompileExecutionGrantInput = {\n\t\tobjectiveId: args.task.objectiveId,\n\t\ttaskId: args.task.taskId,\n\t\tattemptId: args.attemptId,\n\t\tsubjectId: args.subjectId,\n\t\trole: profile.role,\n\t\trequiredCapabilities: args.task.requiredCapabilities,\n\t\trequestedCapabilities: args.task.requiredCapabilities,\n\t\tauthorityCapabilities: profile.capabilityCeiling,\n\t\trequestedTools,\n\t\ttoolManifests: args.toolManifests,\n\t\tresources: selectedResources,\n\t\treadPaths: args.readPaths,\n\t\twritePaths: args.writePaths,\n\t\tdeniedPaths: args.deniedPaths,\n\t\trequestedBudget: profile.budget,\n\t\tauthorityBudget: profile.budget,\n\t\tpolicyVersion: args.policyVersion,\n\t};\n\tconst compiled = args.policyCompiler.compile(policyInput);\n\tif (compiled.outcome !== \"allow\") return compiled;\n\treturn { outcome: \"allow\", plan: { profile, model, grant: compiled.grant, toolManifests: compiled.toolManifests } };\n}\n"]}