omk-adaptorch-wpl 0.96.2 → 0.97.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@
13
13
  * `diagnostics.py::EXPECTED_CORE_TOOLS`. There are exactly 10 real tools;
14
14
  * no "benchmark" or "verification" tools exist in the shipped surface.
15
15
  */
16
- import type { TopologyClassification } from "./types.ts";
16
+ import { type TopologyClassification } from "./types.ts";
17
17
  /**
18
18
  * Abstract transport for invoking AdaptOrch MCP tools by name.
19
19
  *
@@ -109,10 +109,9 @@ export interface AdaptOrchTraceSpan {
109
109
  /**
110
110
  * Result of `adaptorch_route_topology`.
111
111
  *
112
- * `classification` is the topology router's decision
113
- * (singleton/pipeline/DAG/ensemble, see doc section "Routing (pre-run
114
- * planning, local/no dispatch)"); `raw` retains the untyped transport
115
- * response for callers that need more than the classification.
112
+ * `classification` is the validated value from the current response's
113
+ * `topology` field; `raw` retains the transport response for callers that
114
+ * need the accompanying reason, stages, or features.
116
115
  */
117
116
  export interface AdaptOrchRouteTopologyResult {
118
117
  classification: TopologyClassification;
@@ -159,11 +158,7 @@ export declare class AdaptOrchClient {
159
158
  * `run_id`.
160
159
  */
161
160
  getTraces(runId: string): Promise<AdaptOrchTraceSpan[]>;
162
- /**
163
- * `adaptorch_route_topology` (read/local). Route a DAG locally through
164
- * AdaptOrch's topology router (singleton/pipeline/DAG/ensemble) without
165
- * submitting a run.
166
- */
161
+ /** Route a DAG locally and fail closed if the MCP response drifts from the current topology contract. */
167
162
  routeTopology(payloadShape: unknown): Promise<AdaptOrchRouteTopologyResult>;
168
163
  /**
169
164
  * `adaptorch_server_metrics` (read/local). Read redacted MCP server
@@ -1 +1 @@
1
- {"version":3,"file":"adaptorch-client.d.ts","sourceRoot":"","sources":["../src/adaptorch-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,C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G,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAEpD;CACD","sourcesContent":["/**\n * AdaptOrch MCP client wrapper.\n *\n * Design-stage / experimental: this module has no production\n * `AdaptOrchTransport` implementation wired in yet. Callers must supply\n * their own transport (e.g. an adapter around an MCP SDK client) until one\n * ships in this package.\n *\n * Tool surface, names, and read/write classification are grounded in\n * `.omk/runs/lazycodex-adaptorch-loop-plan-20260701/lane2-adaptorch-tool-surface.md`,\n * which cross-checks the real AdaptOrch MCP server against\n * `docs/tools.md`, `README.md`, `mcp_server.py` dispatch, and\n * `diagnostics.py::EXPECTED_CORE_TOOLS`. There are exactly 10 real tools;\n * no \"benchmark\" or \"verification\" tools exist in the shipped surface.\n */\n\nimport type { TopologyClassification } from \"./types.ts\";\n\n/**\n * Abstract transport for invoking AdaptOrch MCP tools by name.\n *\n * See doc section \"The real, current 10-tool MCP surface (grouped)\". No\n * concrete implementation ships with this package yet; a caller must\n * provide one (e.g. wrapping an MCP SDK client's `callTool`).\n */\nexport interface AdaptOrchTransport {\n\tcallTool(name: string, args: Record<string, unknown>): Promise<unknown>;\n}\n\n/**\n * Payload accepted by `adaptorch_run`.\n *\n * See doc section \"Run / lifecycle (submit, inspect, list, cancel)\":\n * `adaptorch_run` submits a task payload (prompt/context/raw payload,\n * connector, synthesis mode, budget policy) to the control-plane, and can\n * optionally block until the run reaches a terminal status.\n */\nexport interface AdaptOrchRunPayload {\n\ttaskPayload: unknown;\n\tconnector?: string;\n\tsynthesisMode?: string;\n\tbudgetPolicy?: unknown;\n\twaitForTerminal?: boolean;\n\ttimeoutSeconds?: number;\n\tpollIntervalSeconds?: number;\n}\n\n/**\n * Result of `adaptorch_run`.\n *\n * Shape is inferred from the doc's description of the tool's purpose, not\n * guaranteed by an official schema.\n */\nexport interface AdaptOrchRunResult {\n\trun_id: string;\n\tstatus?: string;\n}\n\n/**\n * Result of `adaptorch_get_run`.\n *\n * Shape is inferred from the doc's description (\"fetch a run summary by\n * run_id\"), not guaranteed by an official schema; extra fields are\n * expected to vary by connector/synthesis mode.\n */\nexport interface AdaptOrchRunSummary {\n\trun_id: string;\n\tstatus: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Entry in the result of `adaptorch_list_runs`.\n *\n * Shape is inferred, not guaranteed by an official schema.\n */\nexport interface AdaptOrchRunListEntry {\n\trun_id: string;\n\tstatus: string;\n}\n\n/**\n * Result of `adaptorch_cancel_run`.\n *\n * Shape is inferred from the doc's description (\"request cancellation of\n * an in-flight run by run_id\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchCancelResult {\n\trun_id: string;\n\tcancelled: boolean;\n}\n\n/**\n * Entry in the result of `adaptorch_get_artifacts`.\n *\n * Shape is inferred from the doc's description (\"fetch artifact metadata\n * for a run\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchArtifact {\n\tpath: string;\n\tsize_bytes?: number;\n\tcreated_at?: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Entry in the result of `adaptorch_get_traces`.\n *\n * Shape is inferred from the doc's description (\"fetch execution traces\n * for a run by run_id\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchTraceSpan {\n\tspan_id?: string;\n\tkind?: string;\n\tseverity?: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Result of `adaptorch_route_topology`.\n *\n * `classification` is the topology router's decision\n * (singleton/pipeline/DAG/ensemble, see doc section \"Routing (pre-run\n * planning, local/no dispatch)\"); `raw` retains the untyped transport\n * response for callers that need more than the classification.\n */\nexport interface AdaptOrchRouteTopologyResult {\n\tclassification: TopologyClassification;\n\traw: unknown;\n}\n\n/**\n * Typed wrapper around the 10 real AdaptOrch MCP tools.\n *\n * See doc section \"The real, current 10-tool MCP surface (grouped)\" for\n * the full tool list, purposes, and read/write classification. This\n * class only translates method calls into `transport.callTool` calls\n * with the exact tool names the doc lists; it does not implement a\n * transport itself.\n */\nexport class AdaptOrchClient {\n\tprivate readonly transport: AdaptOrchTransport;\n\n\tconstructor(transport: AdaptOrchTransport) {\n\t\tthis.transport = transport;\n\t}\n\n\t/**\n\t * `adaptorch_run` (write). Submit a task payload to the control-plane,\n\t * optionally blocking until the run reaches a terminal status.\n\t */\n\tasync run(payload: AdaptOrchRunPayload): Promise<AdaptOrchRunResult> {\n\t\t// The transport result shape is not schema-validated here; callers\n\t\t// relying on strict correctness should validate at the transport\n\t\t// boundary.\n\t\treturn (await this.transport.callTool(\"adaptorch_run\", { ...payload })) as AdaptOrchRunResult;\n\t}\n\n\t/**\n\t * `adaptorch_get_run` (read). Fetch a run summary by `run_id`.\n\t */\n\tasync getRun(runId: string): Promise<AdaptOrchRunSummary> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_run\", { run_id: runId })) as AdaptOrchRunSummary;\n\t}\n\n\t/**\n\t * `adaptorch_list_runs` (read). List recent control-plane runs.\n\t */\n\tasync listRuns(params?: { limit?: number }): Promise<AdaptOrchRunListEntry[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_list_runs\", { ...params })) as AdaptOrchRunListEntry[];\n\t}\n\n\t/**\n\t * `adaptorch_cancel_run` (write). Request cancellation of an in-flight\n\t * run by `run_id`.\n\t */\n\tasync cancelRun(runId: string): Promise<AdaptOrchCancelResult> {\n\t\treturn (await this.transport.callTool(\"adaptorch_cancel_run\", { run_id: runId })) as AdaptOrchCancelResult;\n\t}\n\n\t/**\n\t * `adaptorch_get_artifacts` (read). Fetch artifact metadata for a run.\n\t */\n\tasync getArtifacts(runId: string): Promise<AdaptOrchArtifact[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_artifacts\", { run_id: runId })) as AdaptOrchArtifact[];\n\t}\n\n\t/**\n\t * `adaptorch_get_traces` (read). Fetch execution traces for a run by\n\t * `run_id`.\n\t */\n\tasync getTraces(runId: string): Promise<AdaptOrchTraceSpan[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_traces\", { run_id: runId })) as AdaptOrchTraceSpan[];\n\t}\n\n\t/**\n\t * `adaptorch_route_topology` (read/local). Route a DAG locally through\n\t * AdaptOrch's topology router (singleton/pipeline/DAG/ensemble) without\n\t * submitting a run.\n\t */\n\tasync routeTopology(payloadShape: unknown): Promise<AdaptOrchRouteTopologyResult> {\n\t\tconst raw = await this.transport.callTool(\"adaptorch_route_topology\", { payload_shape: payloadShape });\n\t\t// The transport response is not schema-validated; classification is\n\t\t// extracted best-effort since no official schema is documented.\n\t\tconst classification = (raw as { classification?: TopologyClassification } | undefined)?.classification;\n\t\treturn {\n\t\t\tclassification: classification as TopologyClassification,\n\t\t\traw,\n\t\t};\n\t}\n\n\t/**\n\t * `adaptorch_server_metrics` (read/local). Read redacted MCP server\n\t * metrics (tool-call counters, latency percentiles).\n\t */\n\tasync serverMetrics(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_server_metrics\", {})) as Record<string, unknown>;\n\t}\n\n\t/**\n\t * `adaptorch_capabilities` (read/local). Read supported synthesis\n\t * modes, connectors, and server features.\n\t */\n\tasync capabilities(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_capabilities\", {})) as Record<string, unknown>;\n\t}\n\n\t/**\n\t * `adaptorch_plan_catalog` (read/local). Read the hosted plan catalog\n\t * (Starter $0 / Pro $39 / Team $149).\n\t */\n\tasync planCatalog(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_plan_catalog\", {})) as Record<string, unknown>;\n\t}\n}\n"]}
1
+ {"version":3,"file":"adaptorch-client.d.ts","sourceRoot":"","sources":["../src/adaptorch-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAA4B,KAAK,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAMnF;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAA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AA4B;IAC5C,cAAc,EAAE,sBAAsB,CAAC;IACvC,GAAG,EAAE,OAAO,CAAC;CACb;AAED;;;;;;;;GAQG;AACH,qBAAa,eAAe;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAE/C,YAAY,SAAS,EAAE,kBAAkB,EAExC;IAED;;;OAGG;IACG,GAAG,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAKnE;IAED;;OAEG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAExD;IAED;;OAEG;IACG,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAE5E;IAED;;;OAGG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAE7D;IAED;;OAEG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAE9D;IAED;;;OAGG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAE5D;IAED,yGAAyG;IACnG,aAAa,CAAC,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAOhF;IAED;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAEtD;IAED;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAErD;IAED;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAEpD;CACD","sourcesContent":["/**\n * AdaptOrch MCP client wrapper.\n *\n * Design-stage / experimental: this module has no production\n * `AdaptOrchTransport` implementation wired in yet. Callers must supply\n * their own transport (e.g. an adapter around an MCP SDK client) until one\n * ships in this package.\n *\n * Tool surface, names, and read/write classification are grounded in\n * `.omk/runs/lazycodex-adaptorch-loop-plan-20260701/lane2-adaptorch-tool-surface.md`,\n * which cross-checks the real AdaptOrch MCP server against\n * `docs/tools.md`, `README.md`, `mcp_server.py` dispatch, and\n * `diagnostics.py::EXPECTED_CORE_TOOLS`. There are exactly 10 real tools;\n * no \"benchmark\" or \"verification\" tools exist in the shipped surface.\n */\n\nimport { isTopologyClassification, type TopologyClassification } from \"./types.ts\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Abstract transport for invoking AdaptOrch MCP tools by name.\n *\n * See doc section \"The real, current 10-tool MCP surface (grouped)\". No\n * concrete implementation ships with this package yet; a caller must\n * provide one (e.g. wrapping an MCP SDK client's `callTool`).\n */\nexport interface AdaptOrchTransport {\n\tcallTool(name: string, args: Record<string, unknown>): Promise<unknown>;\n}\n\n/**\n * Payload accepted by `adaptorch_run`.\n *\n * See doc section \"Run / lifecycle (submit, inspect, list, cancel)\":\n * `adaptorch_run` submits a task payload (prompt/context/raw payload,\n * connector, synthesis mode, budget policy) to the control-plane, and can\n * optionally block until the run reaches a terminal status.\n */\nexport interface AdaptOrchRunPayload {\n\ttaskPayload: unknown;\n\tconnector?: string;\n\tsynthesisMode?: string;\n\tbudgetPolicy?: unknown;\n\twaitForTerminal?: boolean;\n\ttimeoutSeconds?: number;\n\tpollIntervalSeconds?: number;\n}\n\n/**\n * Result of `adaptorch_run`.\n *\n * Shape is inferred from the doc's description of the tool's purpose, not\n * guaranteed by an official schema.\n */\nexport interface AdaptOrchRunResult {\n\trun_id: string;\n\tstatus?: string;\n}\n\n/**\n * Result of `adaptorch_get_run`.\n *\n * Shape is inferred from the doc's description (\"fetch a run summary by\n * run_id\"), not guaranteed by an official schema; extra fields are\n * expected to vary by connector/synthesis mode.\n */\nexport interface AdaptOrchRunSummary {\n\trun_id: string;\n\tstatus: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Entry in the result of `adaptorch_list_runs`.\n *\n * Shape is inferred, not guaranteed by an official schema.\n */\nexport interface AdaptOrchRunListEntry {\n\trun_id: string;\n\tstatus: string;\n}\n\n/**\n * Result of `adaptorch_cancel_run`.\n *\n * Shape is inferred from the doc's description (\"request cancellation of\n * an in-flight run by run_id\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchCancelResult {\n\trun_id: string;\n\tcancelled: boolean;\n}\n\n/**\n * Entry in the result of `adaptorch_get_artifacts`.\n *\n * Shape is inferred from the doc's description (\"fetch artifact metadata\n * for a run\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchArtifact {\n\tpath: string;\n\tsize_bytes?: number;\n\tcreated_at?: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Entry in the result of `adaptorch_get_traces`.\n *\n * Shape is inferred from the doc's description (\"fetch execution traces\n * for a run by run_id\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchTraceSpan {\n\tspan_id?: string;\n\tkind?: string;\n\tseverity?: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Result of `adaptorch_route_topology`.\n *\n * `classification` is the validated value from the current response's\n * `topology` field; `raw` retains the transport response for callers that\n * need the accompanying reason, stages, or features.\n */\nexport interface AdaptOrchRouteTopologyResult {\n\tclassification: TopologyClassification;\n\traw: unknown;\n}\n\n/**\n * Typed wrapper around the 10 real AdaptOrch MCP tools.\n *\n * See doc section \"The real, current 10-tool MCP surface (grouped)\" for\n * the full tool list, purposes, and read/write classification. This\n * class only translates method calls into `transport.callTool` calls\n * with the exact tool names the doc lists; it does not implement a\n * transport itself.\n */\nexport class AdaptOrchClient {\n\tprivate readonly transport: AdaptOrchTransport;\n\n\tconstructor(transport: AdaptOrchTransport) {\n\t\tthis.transport = transport;\n\t}\n\n\t/**\n\t * `adaptorch_run` (write). Submit a task payload to the control-plane,\n\t * optionally blocking until the run reaches a terminal status.\n\t */\n\tasync run(payload: AdaptOrchRunPayload): Promise<AdaptOrchRunResult> {\n\t\t// The transport result shape is not schema-validated here; callers\n\t\t// relying on strict correctness should validate at the transport\n\t\t// boundary.\n\t\treturn (await this.transport.callTool(\"adaptorch_run\", { ...payload })) as AdaptOrchRunResult;\n\t}\n\n\t/**\n\t * `adaptorch_get_run` (read). Fetch a run summary by `run_id`.\n\t */\n\tasync getRun(runId: string): Promise<AdaptOrchRunSummary> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_run\", { run_id: runId })) as AdaptOrchRunSummary;\n\t}\n\n\t/**\n\t * `adaptorch_list_runs` (read). List recent control-plane runs.\n\t */\n\tasync listRuns(params?: { limit?: number }): Promise<AdaptOrchRunListEntry[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_list_runs\", { ...params })) as AdaptOrchRunListEntry[];\n\t}\n\n\t/**\n\t * `adaptorch_cancel_run` (write). Request cancellation of an in-flight\n\t * run by `run_id`.\n\t */\n\tasync cancelRun(runId: string): Promise<AdaptOrchCancelResult> {\n\t\treturn (await this.transport.callTool(\"adaptorch_cancel_run\", { run_id: runId })) as AdaptOrchCancelResult;\n\t}\n\n\t/**\n\t * `adaptorch_get_artifacts` (read). Fetch artifact metadata for a run.\n\t */\n\tasync getArtifacts(runId: string): Promise<AdaptOrchArtifact[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_artifacts\", { run_id: runId })) as AdaptOrchArtifact[];\n\t}\n\n\t/**\n\t * `adaptorch_get_traces` (read). Fetch execution traces for a run by\n\t * `run_id`.\n\t */\n\tasync getTraces(runId: string): Promise<AdaptOrchTraceSpan[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_traces\", { run_id: runId })) as AdaptOrchTraceSpan[];\n\t}\n\n\t/** Route a DAG locally and fail closed if the MCP response drifts from the current topology contract. */\n\tasync routeTopology(payloadShape: unknown): Promise<AdaptOrchRouteTopologyResult> {\n\t\tconst raw = await this.transport.callTool(\"adaptorch_route_topology\", { payload_shape: payloadShape });\n\t\tconst topology = isRecord(raw) ? raw.topology : undefined;\n\t\tif (!isTopologyClassification(topology)) {\n\t\t\tthrow new Error(\"AdaptOrch route response has invalid topology\");\n\t\t}\n\t\treturn { classification: topology, raw };\n\t}\n\n\t/**\n\t * `adaptorch_server_metrics` (read/local). Read redacted MCP server\n\t * metrics (tool-call counters, latency percentiles).\n\t */\n\tasync serverMetrics(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_server_metrics\", {})) as Record<string, unknown>;\n\t}\n\n\t/**\n\t * `adaptorch_capabilities` (read/local). Read supported synthesis\n\t * modes, connectors, and server features.\n\t */\n\tasync capabilities(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_capabilities\", {})) as Record<string, unknown>;\n\t}\n\n\t/**\n\t * `adaptorch_plan_catalog` (read/local). Read the hosted plan catalog\n\t * (Starter $0 / Pro $39 / Team $149).\n\t */\n\tasync planCatalog(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_plan_catalog\", {})) as Record<string, unknown>;\n\t}\n}\n"]}
@@ -13,6 +13,10 @@
13
13
  * `diagnostics.py::EXPECTED_CORE_TOOLS`. There are exactly 10 real tools;
14
14
  * no "benchmark" or "verification" tools exist in the shipped surface.
15
15
  */
16
+ import { isTopologyClassification } from "./types.js";
17
+ function isRecord(value) {
18
+ return typeof value === "object" && value !== null && !Array.isArray(value);
19
+ }
16
20
  /**
17
21
  * Typed wrapper around the 10 real AdaptOrch MCP tools.
18
22
  *
@@ -69,20 +73,14 @@ export class AdaptOrchClient {
69
73
  async getTraces(runId) {
70
74
  return (await this.transport.callTool("adaptorch_get_traces", { run_id: runId }));
71
75
  }
72
- /**
73
- * `adaptorch_route_topology` (read/local). Route a DAG locally through
74
- * AdaptOrch's topology router (singleton/pipeline/DAG/ensemble) without
75
- * submitting a run.
76
- */
76
+ /** Route a DAG locally and fail closed if the MCP response drifts from the current topology contract. */
77
77
  async routeTopology(payloadShape) {
78
78
  const raw = await this.transport.callTool("adaptorch_route_topology", { payload_shape: payloadShape });
79
- // The transport response is not schema-validated; classification is
80
- // extracted best-effort since no official schema is documented.
81
- const classification = raw?.classification;
82
- return {
83
- classification: classification,
84
- raw,
85
- };
79
+ const topology = isRecord(raw) ? raw.topology : undefined;
80
+ if (!isTopologyClassification(topology)) {
81
+ throw new Error("AdaptOrch route response has invalid topology");
82
+ }
83
+ return { classification: topology, raw };
86
84
  }
87
85
  /**
88
86
  * `adaptorch_server_metrics` (read/local). Read redacted MCP server
@@ -1 +1 @@
1
- {"version":3,"file":"adaptorch-client.js","sourceRoot":"","sources":["../src/adaptorch-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAqHH;;;;;;;;GAQG;AACH,MAAM,OAAO,eAAe;IACV,SAAS,CAAqB;IAE/C,YAAY,SAA6B,EAAE;QAC1C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAAA,CAC3B;IAED;;;OAGG;IACH,KAAK,CAAC,GAAG,CAAC,OAA4B,EAA+B;QACpE,mEAAmE;QACnE,iEAAiE;QACjE,YAAY;QACZ,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAuB,CAAC;IAAA,CAC9F;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,KAAa,EAAgC;QACzD,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,mBAAmB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAwB,CAAC;IAAA,CACtG;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAC,MAA2B,EAAoC;QAC7E,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,qBAAqB,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC,CAA4B,CAAC;IAAA,CACxG;IAED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GG;IACH,KAAK,CAAC,WAAW,GAAqC;QACrD,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAA4B,CAAC;IAAA,CAChG;CACD","sourcesContent":["/**\n * AdaptOrch MCP client wrapper.\n *\n * Design-stage / experimental: this module has no production\n * `AdaptOrchTransport` implementation wired in yet. Callers must supply\n * their own transport (e.g. an adapter around an MCP SDK client) until one\n * ships in this package.\n *\n * Tool surface, names, and read/write classification are grounded in\n * `.omk/runs/lazycodex-adaptorch-loop-plan-20260701/lane2-adaptorch-tool-surface.md`,\n * which cross-checks the real AdaptOrch MCP server against\n * `docs/tools.md`, `README.md`, `mcp_server.py` dispatch, and\n * `diagnostics.py::EXPECTED_CORE_TOOLS`. There are exactly 10 real tools;\n * no \"benchmark\" or \"verification\" tools exist in the shipped surface.\n */\n\nimport type { TopologyClassification } from \"./types.ts\";\n\n/**\n * Abstract transport for invoking AdaptOrch MCP tools by name.\n *\n * See doc section \"The real, current 10-tool MCP surface (grouped)\". No\n * concrete implementation ships with this package yet; a caller must\n * provide one (e.g. wrapping an MCP SDK client's `callTool`).\n */\nexport interface AdaptOrchTransport {\n\tcallTool(name: string, args: Record<string, unknown>): Promise<unknown>;\n}\n\n/**\n * Payload accepted by `adaptorch_run`.\n *\n * See doc section \"Run / lifecycle (submit, inspect, list, cancel)\":\n * `adaptorch_run` submits a task payload (prompt/context/raw payload,\n * connector, synthesis mode, budget policy) to the control-plane, and can\n * optionally block until the run reaches a terminal status.\n */\nexport interface AdaptOrchRunPayload {\n\ttaskPayload: unknown;\n\tconnector?: string;\n\tsynthesisMode?: string;\n\tbudgetPolicy?: unknown;\n\twaitForTerminal?: boolean;\n\ttimeoutSeconds?: number;\n\tpollIntervalSeconds?: number;\n}\n\n/**\n * Result of `adaptorch_run`.\n *\n * Shape is inferred from the doc's description of the tool's purpose, not\n * guaranteed by an official schema.\n */\nexport interface AdaptOrchRunResult {\n\trun_id: string;\n\tstatus?: string;\n}\n\n/**\n * Result of `adaptorch_get_run`.\n *\n * Shape is inferred from the doc's description (\"fetch a run summary by\n * run_id\"), not guaranteed by an official schema; extra fields are\n * expected to vary by connector/synthesis mode.\n */\nexport interface AdaptOrchRunSummary {\n\trun_id: string;\n\tstatus: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Entry in the result of `adaptorch_list_runs`.\n *\n * Shape is inferred, not guaranteed by an official schema.\n */\nexport interface AdaptOrchRunListEntry {\n\trun_id: string;\n\tstatus: string;\n}\n\n/**\n * Result of `adaptorch_cancel_run`.\n *\n * Shape is inferred from the doc's description (\"request cancellation of\n * an in-flight run by run_id\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchCancelResult {\n\trun_id: string;\n\tcancelled: boolean;\n}\n\n/**\n * Entry in the result of `adaptorch_get_artifacts`.\n *\n * Shape is inferred from the doc's description (\"fetch artifact metadata\n * for a run\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchArtifact {\n\tpath: string;\n\tsize_bytes?: number;\n\tcreated_at?: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Entry in the result of `adaptorch_get_traces`.\n *\n * Shape is inferred from the doc's description (\"fetch execution traces\n * for a run by run_id\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchTraceSpan {\n\tspan_id?: string;\n\tkind?: string;\n\tseverity?: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Result of `adaptorch_route_topology`.\n *\n * `classification` is the topology router's decision\n * (singleton/pipeline/DAG/ensemble, see doc section \"Routing (pre-run\n * planning, local/no dispatch)\"); `raw` retains the untyped transport\n * response for callers that need more than the classification.\n */\nexport interface AdaptOrchRouteTopologyResult {\n\tclassification: TopologyClassification;\n\traw: unknown;\n}\n\n/**\n * Typed wrapper around the 10 real AdaptOrch MCP tools.\n *\n * See doc section \"The real, current 10-tool MCP surface (grouped)\" for\n * the full tool list, purposes, and read/write classification. This\n * class only translates method calls into `transport.callTool` calls\n * with the exact tool names the doc lists; it does not implement a\n * transport itself.\n */\nexport class AdaptOrchClient {\n\tprivate readonly transport: AdaptOrchTransport;\n\n\tconstructor(transport: AdaptOrchTransport) {\n\t\tthis.transport = transport;\n\t}\n\n\t/**\n\t * `adaptorch_run` (write). Submit a task payload to the control-plane,\n\t * optionally blocking until the run reaches a terminal status.\n\t */\n\tasync run(payload: AdaptOrchRunPayload): Promise<AdaptOrchRunResult> {\n\t\t// The transport result shape is not schema-validated here; callers\n\t\t// relying on strict correctness should validate at the transport\n\t\t// boundary.\n\t\treturn (await this.transport.callTool(\"adaptorch_run\", { ...payload })) as AdaptOrchRunResult;\n\t}\n\n\t/**\n\t * `adaptorch_get_run` (read). Fetch a run summary by `run_id`.\n\t */\n\tasync getRun(runId: string): Promise<AdaptOrchRunSummary> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_run\", { run_id: runId })) as AdaptOrchRunSummary;\n\t}\n\n\t/**\n\t * `adaptorch_list_runs` (read). List recent control-plane runs.\n\t */\n\tasync listRuns(params?: { limit?: number }): Promise<AdaptOrchRunListEntry[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_list_runs\", { ...params })) as AdaptOrchRunListEntry[];\n\t}\n\n\t/**\n\t * `adaptorch_cancel_run` (write). Request cancellation of an in-flight\n\t * run by `run_id`.\n\t */\n\tasync cancelRun(runId: string): Promise<AdaptOrchCancelResult> {\n\t\treturn (await this.transport.callTool(\"adaptorch_cancel_run\", { run_id: runId })) as AdaptOrchCancelResult;\n\t}\n\n\t/**\n\t * `adaptorch_get_artifacts` (read). Fetch artifact metadata for a run.\n\t */\n\tasync getArtifacts(runId: string): Promise<AdaptOrchArtifact[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_artifacts\", { run_id: runId })) as AdaptOrchArtifact[];\n\t}\n\n\t/**\n\t * `adaptorch_get_traces` (read). Fetch execution traces for a run by\n\t * `run_id`.\n\t */\n\tasync getTraces(runId: string): Promise<AdaptOrchTraceSpan[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_traces\", { run_id: runId })) as AdaptOrchTraceSpan[];\n\t}\n\n\t/**\n\t * `adaptorch_route_topology` (read/local). Route a DAG locally through\n\t * AdaptOrch's topology router (singleton/pipeline/DAG/ensemble) without\n\t * submitting a run.\n\t */\n\tasync routeTopology(payloadShape: unknown): Promise<AdaptOrchRouteTopologyResult> {\n\t\tconst raw = await this.transport.callTool(\"adaptorch_route_topology\", { payload_shape: payloadShape });\n\t\t// The transport response is not schema-validated; classification is\n\t\t// extracted best-effort since no official schema is documented.\n\t\tconst classification = (raw as { classification?: TopologyClassification } | undefined)?.classification;\n\t\treturn {\n\t\t\tclassification: classification as TopologyClassification,\n\t\t\traw,\n\t\t};\n\t}\n\n\t/**\n\t * `adaptorch_server_metrics` (read/local). Read redacted MCP server\n\t * metrics (tool-call counters, latency percentiles).\n\t */\n\tasync serverMetrics(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_server_metrics\", {})) as Record<string, unknown>;\n\t}\n\n\t/**\n\t * `adaptorch_capabilities` (read/local). Read supported synthesis\n\t * modes, connectors, and server features.\n\t */\n\tasync capabilities(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_capabilities\", {})) as Record<string, unknown>;\n\t}\n\n\t/**\n\t * `adaptorch_plan_catalog` (read/local). Read the hosted plan catalog\n\t * (Starter $0 / Pro $39 / Team $149).\n\t */\n\tasync planCatalog(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_plan_catalog\", {})) as Record<string, unknown>;\n\t}\n}\n"]}
1
+ {"version":3,"file":"adaptorch-client.js","sourceRoot":"","sources":["../src/adaptorch-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,wBAAwB,EAA+B,MAAM,YAAY,CAAC;AAEnF,SAAS,QAAQ,CAAC,KAAc,EAAoC;IACnE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,I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KAAK,CAAC,SAAS,CAAC,KAAa,EAAiC;QAC7D,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAyB,CAAC;IAAA,CAC1G;IAED,yGAAyG;IACzG,KAAK,CAAC,aAAa,CAAC,YAAqB,EAAyC;QACjF,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,0BAA0B,EAAE,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC,CAAC;QACvG,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1D,IAAI,CAAC,wBAAwB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;IAAA,CACzC;IAED;;;OAGG;IACH,KAAK,CAAC,aAAa,GAAqC;QACvD,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,0BAA0B,EAAE,EAAE,CAAC,CAA4B,CAAC;IAAA,CAClG;IAED;;;OAGG;IACH,KAAK,CAAC,YAAY,GAAqC;QACtD,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAA4B,CAAC;IAAA,CAChG;IAED;;;OAGG;IACH,KAAK,CAAC,WAAW,GAAqC;QACrD,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAA4B,CAAC;IAAA,CAChG;CACD","sourcesContent":["/**\n * AdaptOrch MCP client wrapper.\n *\n * Design-stage / experimental: this module has no production\n * `AdaptOrchTransport` implementation wired in yet. Callers must supply\n * their own transport (e.g. an adapter around an MCP SDK client) until one\n * ships in this package.\n *\n * Tool surface, names, and read/write classification are grounded in\n * `.omk/runs/lazycodex-adaptorch-loop-plan-20260701/lane2-adaptorch-tool-surface.md`,\n * which cross-checks the real AdaptOrch MCP server against\n * `docs/tools.md`, `README.md`, `mcp_server.py` dispatch, and\n * `diagnostics.py::EXPECTED_CORE_TOOLS`. There are exactly 10 real tools;\n * no \"benchmark\" or \"verification\" tools exist in the shipped surface.\n */\n\nimport { isTopologyClassification, type TopologyClassification } from \"./types.ts\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Abstract transport for invoking AdaptOrch MCP tools by name.\n *\n * See doc section \"The real, current 10-tool MCP surface (grouped)\". No\n * concrete implementation ships with this package yet; a caller must\n * provide one (e.g. wrapping an MCP SDK client's `callTool`).\n */\nexport interface AdaptOrchTransport {\n\tcallTool(name: string, args: Record<string, unknown>): Promise<unknown>;\n}\n\n/**\n * Payload accepted by `adaptorch_run`.\n *\n * See doc section \"Run / lifecycle (submit, inspect, list, cancel)\":\n * `adaptorch_run` submits a task payload (prompt/context/raw payload,\n * connector, synthesis mode, budget policy) to the control-plane, and can\n * optionally block until the run reaches a terminal status.\n */\nexport interface AdaptOrchRunPayload {\n\ttaskPayload: unknown;\n\tconnector?: string;\n\tsynthesisMode?: string;\n\tbudgetPolicy?: unknown;\n\twaitForTerminal?: boolean;\n\ttimeoutSeconds?: number;\n\tpollIntervalSeconds?: number;\n}\n\n/**\n * Result of `adaptorch_run`.\n *\n * Shape is inferred from the doc's description of the tool's purpose, not\n * guaranteed by an official schema.\n */\nexport interface AdaptOrchRunResult {\n\trun_id: string;\n\tstatus?: string;\n}\n\n/**\n * Result of `adaptorch_get_run`.\n *\n * Shape is inferred from the doc's description (\"fetch a run summary by\n * run_id\"), not guaranteed by an official schema; extra fields are\n * expected to vary by connector/synthesis mode.\n */\nexport interface AdaptOrchRunSummary {\n\trun_id: string;\n\tstatus: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Entry in the result of `adaptorch_list_runs`.\n *\n * Shape is inferred, not guaranteed by an official schema.\n */\nexport interface AdaptOrchRunListEntry {\n\trun_id: string;\n\tstatus: string;\n}\n\n/**\n * Result of `adaptorch_cancel_run`.\n *\n * Shape is inferred from the doc's description (\"request cancellation of\n * an in-flight run by run_id\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchCancelResult {\n\trun_id: string;\n\tcancelled: boolean;\n}\n\n/**\n * Entry in the result of `adaptorch_get_artifacts`.\n *\n * Shape is inferred from the doc's description (\"fetch artifact metadata\n * for a run\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchArtifact {\n\tpath: string;\n\tsize_bytes?: number;\n\tcreated_at?: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Entry in the result of `adaptorch_get_traces`.\n *\n * Shape is inferred from the doc's description (\"fetch execution traces\n * for a run by run_id\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchTraceSpan {\n\tspan_id?: string;\n\tkind?: string;\n\tseverity?: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Result of `adaptorch_route_topology`.\n *\n * `classification` is the validated value from the current response's\n * `topology` field; `raw` retains the transport response for callers that\n * need the accompanying reason, stages, or features.\n */\nexport interface AdaptOrchRouteTopologyResult {\n\tclassification: TopologyClassification;\n\traw: unknown;\n}\n\n/**\n * Typed wrapper around the 10 real AdaptOrch MCP tools.\n *\n * See doc section \"The real, current 10-tool MCP surface (grouped)\" for\n * the full tool list, purposes, and read/write classification. This\n * class only translates method calls into `transport.callTool` calls\n * with the exact tool names the doc lists; it does not implement a\n * transport itself.\n */\nexport class AdaptOrchClient {\n\tprivate readonly transport: AdaptOrchTransport;\n\n\tconstructor(transport: AdaptOrchTransport) {\n\t\tthis.transport = transport;\n\t}\n\n\t/**\n\t * `adaptorch_run` (write). Submit a task payload to the control-plane,\n\t * optionally blocking until the run reaches a terminal status.\n\t */\n\tasync run(payload: AdaptOrchRunPayload): Promise<AdaptOrchRunResult> {\n\t\t// The transport result shape is not schema-validated here; callers\n\t\t// relying on strict correctness should validate at the transport\n\t\t// boundary.\n\t\treturn (await this.transport.callTool(\"adaptorch_run\", { ...payload })) as AdaptOrchRunResult;\n\t}\n\n\t/**\n\t * `adaptorch_get_run` (read). Fetch a run summary by `run_id`.\n\t */\n\tasync getRun(runId: string): Promise<AdaptOrchRunSummary> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_run\", { run_id: runId })) as AdaptOrchRunSummary;\n\t}\n\n\t/**\n\t * `adaptorch_list_runs` (read). List recent control-plane runs.\n\t */\n\tasync listRuns(params?: { limit?: number }): Promise<AdaptOrchRunListEntry[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_list_runs\", { ...params })) as AdaptOrchRunListEntry[];\n\t}\n\n\t/**\n\t * `adaptorch_cancel_run` (write). Request cancellation of an in-flight\n\t * run by `run_id`.\n\t */\n\tasync cancelRun(runId: string): Promise<AdaptOrchCancelResult> {\n\t\treturn (await this.transport.callTool(\"adaptorch_cancel_run\", { run_id: runId })) as AdaptOrchCancelResult;\n\t}\n\n\t/**\n\t * `adaptorch_get_artifacts` (read). Fetch artifact metadata for a run.\n\t */\n\tasync getArtifacts(runId: string): Promise<AdaptOrchArtifact[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_artifacts\", { run_id: runId })) as AdaptOrchArtifact[];\n\t}\n\n\t/**\n\t * `adaptorch_get_traces` (read). Fetch execution traces for a run by\n\t * `run_id`.\n\t */\n\tasync getTraces(runId: string): Promise<AdaptOrchTraceSpan[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_traces\", { run_id: runId })) as AdaptOrchTraceSpan[];\n\t}\n\n\t/** Route a DAG locally and fail closed if the MCP response drifts from the current topology contract. */\n\tasync routeTopology(payloadShape: unknown): Promise<AdaptOrchRouteTopologyResult> {\n\t\tconst raw = await this.transport.callTool(\"adaptorch_route_topology\", { payload_shape: payloadShape });\n\t\tconst topology = isRecord(raw) ? raw.topology : undefined;\n\t\tif (!isTopologyClassification(topology)) {\n\t\t\tthrow new Error(\"AdaptOrch route response has invalid topology\");\n\t\t}\n\t\treturn { classification: topology, raw };\n\t}\n\n\t/**\n\t * `adaptorch_server_metrics` (read/local). Read redacted MCP server\n\t * metrics (tool-call counters, latency percentiles).\n\t */\n\tasync serverMetrics(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_server_metrics\", {})) as Record<string, unknown>;\n\t}\n\n\t/**\n\t * `adaptorch_capabilities` (read/local). Read supported synthesis\n\t * modes, connectors, and server features.\n\t */\n\tasync capabilities(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_capabilities\", {})) as Record<string, unknown>;\n\t}\n\n\t/**\n\t * `adaptorch_plan_catalog` (read/local). Read the hosted plan catalog\n\t * (Starter $0 / Pro $39 / Team $149).\n\t */\n\tasync planCatalog(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_plan_catalog\", {})) as Record<string, unknown>;\n\t}\n}\n"]}
package/dist/types.d.ts CHANGED
@@ -18,11 +18,10 @@ export type WorkPacketState = "DRAFTED" | "ROUTED" | "AWAITING_APPROVAL" | "DISP
18
18
  * single-call-vs-client-side-fanout ambiguity.
19
19
  */
20
20
  export type CardinalityMode = "single_call" | "fanout_n";
21
- /**
22
- * Part 1 §3.1 the four topology classes `adaptorch_route_topology` can return for a
23
- * packet's payload, decided once per packet before any `adaptorch_run` call.
24
- */
25
- export type TopologyClassification = "singleton" | "pipeline" | "dag" | "ensemble";
21
+ /** Current `adaptorch_route_topology` values, synchronized with AdaptOrch's `Topology` enum. */
22
+ export declare const TOPOLOGY_CLASSIFICATIONS: readonly ["parallel", "sequential", "hierarchical", "hybrid", "multi_model_ensemble", "multi_turn_debate"];
23
+ export type TopologyClassification = (typeof TOPOLOGY_CLASSIFICATIONS)[number];
24
+ export declare function isTopologyClassification(value: unknown): value is TopologyClassification;
26
25
  /**
27
26
  * Part 1 §3.3 / §7 — one concrete submission attempt for a Work Packet. A Dispatch Record
28
27
  * holds a run_id *set* (not a single run_id) tagged with its cardinality mode, so polling,
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GACxB,SAAS,GACT,QAAQ,GACR,mBAAmB,GACnB,YAAY,GACZ,QAAQ,GACR,SAAS,GACT,cAAc,GACd,cAAc,GACd,qBAAqB,GACrB,WAAW,GACX,UAAU,GACV,cAAc,GACd,WAAW,GACX,QAAQ,CAAC;AAEZ;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,UAAU,CAAC;AAEzD;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,WAAW,GAAG,UAAU,GAAG,KAAK,GAAG,UAAU,CAAC;AAEnF;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,eAAe,CAAC;IAClC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,eAAe,CAAC;IACtB,EAAE,EAAE,eAAe,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,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MAAM,WAAW,YAAY,CAAC;AACrC,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AACrD,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,eAAe,oBAAoB,CAAC;AACjD,eAAO,MAAM,iBAAiB,kBAAkB,CAAC","sourcesContent":["/**\n * Design-fidelity note: this file implements the Work Packet on-disk schema and supporting\n * type vocabulary defined in Part 1 (`final-part1-core-algorithm.md`), Sections 1, 2, 3, 4,\n * and 7. It is an implementation of that document, not a restatement of it — see the design\n * doc for rationale, transition semantics, and the open questions left for other lanes.\n */\n\n/**\n * Work Packet lifecycle states.\n *\n * Part 1 §2 — the fourteen states of the packet-level state machine, including the\n * ESCALATED / AWAITING_APPROVAL / ADJUDICATION_FAILED additions from this revision.\n */\nexport type WorkPacketState =\n\t| \"DRAFTED\"\n\t| \"ROUTED\"\n\t| \"AWAITING_APPROVAL\"\n\t| \"DISPATCHED\"\n\t| \"ACTIVE\"\n\t| \"HALTING\"\n\t| \"RAW_TERMINAL\"\n\t| \"UNDER_REVIEW\"\n\t| \"ADJUDICATION_FAILED\"\n\t| \"CONFIRMED\"\n\t| \"DECLINED\"\n\t| \"RETRY_QUEUED\"\n\t| \"ESCALATED\"\n\t| \"CLOSED\";\n\n/**\n * Part 1 §3.3 — whether a Dispatch Record's run_id set was produced by a single\n * `adaptorch_run` call (`single_call`) or by N calls the loop itself issued (`fanout_n`).\n * This tag is what lets the rest of the state machine stay agnostic to the Section 3.2\n * single-call-vs-client-side-fanout ambiguity.\n */\nexport type CardinalityMode = \"single_call\" | \"fanout_n\";\n\n/**\n * Part 1 §3.1 — the four topology classes `adaptorch_route_topology` can return for a\n * packet's payload, decided once per packet before any `adaptorch_run` call.\n */\nexport type TopologyClassification = \"singleton\" | \"pipeline\" | \"dag\" | \"ensemble\";\n\n/**\n * Part 1 §3.3 / §7 — one concrete submission attempt for a Work Packet. A Dispatch Record\n * holds a run_id *set* (not a single run_id) tagged with its cardinality mode, so polling,\n * cancellation, and review packaging work the same way regardless of which Section 3.2\n * reading turns out to be correct.\n */\nexport interface DispatchRecord {\n\tattempt_n: number;\n\tcardinality_mode: CardinalityMode;\n\trun_ids: string[];\n\tsubmitted_at: string;\n\tmode: \"blocking\" | \"polling\";\n\tterminal_status?: string;\n\tterminal_at?: string;\n}\n\n/**\n * Part 1 §7 — one append-only entry in a Work Packet's transition log. Recorded for every\n * state change, including adjudication-call failures that have no `AdjudicationResult` to\n * archive elsewhere.\n */\nexport interface TransitionLogEntry {\n\tfrom: WorkPacketState;\n\tto: WorkPacketState;\n\tat: string;\n\tcause: string;\n}\n\n/**\n * Part 1 §1 / §7 — the Work Packet: the durable unit of intent this loop manages, potentially\n * resubmitted across several Dispatch Records over its life.\n *\n * The design doc (§7) also describes `adjudication_retry_count` (a separate bounded counter\n * for retrying the `adjudicate()` call itself, Part 1 §2/§6) and\n * `last_human_approved_topology_class` as persisted fields. Those are not modeled on this\n * type in this cut; a later change can add them without breaking the fields defined here.\n */\nexport interface WorkPacket {\n\tpacket_id: string;\n\tkind: string;\n\tcreated_at: string;\n\tpayload: unknown;\n\ttopology_decision: {\n\t\tclassification: TopologyClassification;\n\t\tdecided_at: string;\n\t\traw_route_response: unknown;\n\t} | null;\n\tdispatch_records: DispatchRecord[];\n\tstate: WorkPacketState;\n\tretry_count: number;\n\ttransition_log: TransitionLogEntry[];\n\tlast_adjudication_ref: string | null;\n\t/** Part 1 §4 — the per-packet attempt budget (`max_dispatch_attempts`) and how much of it has been used. */\n\tattempt_budget: {\n\t\tmax_dispatch_attempts: number;\n\t\tdispatch_attempts_used: number;\n\t};\n\t/**\n\t * Part 1 §2 state 3 / §7 — the payload most recently approved by a human reviewer (or the\n\t * original payload at creation, implicitly approved). `null` only if the packet has not yet\n\t * been assigned an initial baseline. Used by `requiresHumanApproval` to decide whether the\n\t * next attempt needs an AWAITING_APPROVAL gate before its first dispatch.\n\t */\n\tlast_human_approved_payload: unknown | null;\n}\n\n/**\n * Part 1 §4 — the named reasons the loop stops admitting new DRAFTED packets and begins\n * draining. `capacity_ceiling` and the cardinality-mismatch guard are soft governors (they\n * reduce admission/concurrency rather than terminating the loop outright); the others are\n * hard termination conditions.\n */\nexport type LoopTerminationCondition =\n\t| \"completion_exhaustion\"\n\t| \"per_packet_attempt_budget\"\n\t| \"wall_clock_budget\"\n\t| \"dispatch_call_budget\"\n\t| \"stagnation_guard\"\n\t| \"capacity_ceiling\"\n\t| \"external_abort\";\n\n/**\n * Part 1 §4 — loop-instance configuration. Per the \"Budget immutability\" rule in §4, every\n * field here is fixed at loop-instance creation and must not be mutated for that instance's\n * lifetime; raising a threshold requires starting a new loop instance.\n */\nexport interface LoopConfig {\n\tloop_instance_id: string;\n\t/** Part 1 §4 \"Per-packet attempt budget\" — illustrative default in the design doc is 3. */\n\tmax_dispatch_attempts_per_packet: number;\n\t/** Part 1 §4 \"Loop wall-clock budget\", expressed in milliseconds. */\n\tmax_loop_duration_ms: number;\n\t/** Part 1 §4 \"Loop dispatch-call budget\" — total `adaptorch_run` invocations allowed across the loop's life. */\n\tmax_total_dispatch_calls: number;\n\t/**\n\t * Part 1 §4 \"Stagnation guard\" — the number of consecutive loop-wide DECLINED verdicts\n\t * with indistinguishable evidence (same reason text / same evidence digest) that triggers\n\t * a halt.\n\t */\n\tstagnation_repeat_threshold: number;\n\t/**\n\t * Part 1 §4 \"Capacity ceiling (soft governor)\". Shape chosen for this implementation, not\n\t * dictated verbatim by the design doc: a saturation fraction/duration pair that must be\n\t * sustained before the governor engages, and the reduced concurrency ceiling it engages to.\n\t */\n\tcapacity_governor_thresholds: {\n\t\t/** Fraction (0-1) of `adaptorch_server_metrics` saturation considered \"sustained saturation\". */\n\t\tsaturation_threshold: number;\n\t\t/** How long saturation must persist, in milliseconds, before the governor engages. */\n\t\tsustained_duration_ms: number;\n\t\t/** Concurrency budget (max packets allowed into ACTIVE at once) while the governor is engaged. */\n\t\treduced_concurrency_ceiling: number;\n\t};\n\t/**\n\t * Part 1 §2 state 3 — the documented opt-in escape hatch that skips AWAITING_APPROVAL\n\t * for every attempt in this loop instance, regardless of payload/topology drift.\n\t */\n\tpre_approved_batch: boolean;\n\t/**\n\t * Part 1 §3.4 — the result of the one-time cardinality calibration probe, or `null` before\n\t * that probe has run. Continuously cross-checked (at zero extra call cost) against later\n\t * `adaptorch_get_run`/reconciliation-sweep observations per §3.4.\n\t */\n\tobserved_cardinality_mode: CardinalityMode | null;\n}\n\n/**\n * Part 1 §7 — on-disk file layout constants, rooted at a loop-instance directory. Exported so\n * other modules never hardcode these path segments.\n */\nexport const PACKETS_DIR = \"packets\";\nexport const PACKET_INDEX_FILE = \"packet_index.json\";\nexport const RUN_MAP_FILE = \"run_map.json\";\nexport const LOOP_STATE_FILE = \"loop_state.json\";\nexport const ADJUDICATIONS_DIR = \"adjudications\";\n"]}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GACxB,SAAS,GACT,QAAQ,GACR,mBAAmB,GACnB,YAAY,GACZ,QAAQ,GACR,SAAS,GACT,cAAc,GACd,cAAc,GACd,qBAAqB,GACrB,WAAW,GACX,UAAU,GACV,cAAc,GACd,WAAW,GACX,QAAQ,CAAC;AAEZ;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,UAAU,CAAC;AAEzD,gGAAgG;AAChG,eAAO,MAAM,wBAAwB,4GAO3B,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAI/E,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,sBAAsB,CAExF;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,eAAe,CAAC;IAClC,OAAO,EAAE,MAAM,EAAE,CAAC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AAE,MAAM,CAAC;IACzC,sEAAqE;IACrE,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mHAAgH;IAChH,wBAAwB,EAAE,MAAM,CAAC;IACjC;;;;OAIG;IACH,2BAA2B,EAAE,MAAM,CAAC;IACpC;;;;OAIG;IACH,4BAA4B,EAAE;QAC7B,iGAAiG;QACjG,oBAAoB,EAAE,MAAM,CAAC;QAC7B,sFAAsF;QACtF,qBAAqB,EAAE,MAAM,CAAC;QAC9B,kGAAkG;QAClG,2BAA2B,EAAE,MAAM,CAAC;KACpC,CAAC;IACF;;;OAGG;IACH,kBAAkB,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,yBAAyB,EAAE,eAAe,GAAG,IAAI,CAAC;CAClD;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,YAAY,CAAC;AACrC,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AACrD,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,eAAe,oBAAoB,CAAC;AACjD,eAAO,MAAM,iBAAiB,kBAAkB,CAAC","sourcesContent":["/**\n * Design-fidelity note: this file implements the Work Packet on-disk schema and supporting\n * type vocabulary defined in Part 1 (`final-part1-core-algorithm.md`), Sections 1, 2, 3, 4,\n * and 7. It is an implementation of that document, not a restatement of it — see the design\n * doc for rationale, transition semantics, and the open questions left for other lanes.\n */\n\n/**\n * Work Packet lifecycle states.\n *\n * Part 1 §2 — the fourteen states of the packet-level state machine, including the\n * ESCALATED / AWAITING_APPROVAL / ADJUDICATION_FAILED additions from this revision.\n */\nexport type WorkPacketState =\n\t| \"DRAFTED\"\n\t| \"ROUTED\"\n\t| \"AWAITING_APPROVAL\"\n\t| \"DISPATCHED\"\n\t| \"ACTIVE\"\n\t| \"HALTING\"\n\t| \"RAW_TERMINAL\"\n\t| \"UNDER_REVIEW\"\n\t| \"ADJUDICATION_FAILED\"\n\t| \"CONFIRMED\"\n\t| \"DECLINED\"\n\t| \"RETRY_QUEUED\"\n\t| \"ESCALATED\"\n\t| \"CLOSED\";\n\n/**\n * Part 1 §3.3 — whether a Dispatch Record's run_id set was produced by a single\n * `adaptorch_run` call (`single_call`) or by N calls the loop itself issued (`fanout_n`).\n * This tag is what lets the rest of the state machine stay agnostic to the Section 3.2\n * single-call-vs-client-side-fanout ambiguity.\n */\nexport type CardinalityMode = \"single_call\" | \"fanout_n\";\n\n/** Current `adaptorch_route_topology` values, synchronized with AdaptOrch's `Topology` enum. */\nexport const TOPOLOGY_CLASSIFICATIONS = [\n\t\"parallel\",\n\t\"sequential\",\n\t\"hierarchical\",\n\t\"hybrid\",\n\t\"multi_model_ensemble\",\n\t\"multi_turn_debate\",\n] as const;\n\nexport type TopologyClassification = (typeof TOPOLOGY_CLASSIFICATIONS)[number];\n\nconst TOPOLOGY_CLASSIFICATION_SET: ReadonlySet<string> = new Set(TOPOLOGY_CLASSIFICATIONS);\n\nexport function isTopologyClassification(value: unknown): value is TopologyClassification {\n\treturn typeof value === \"string\" && TOPOLOGY_CLASSIFICATION_SET.has(value);\n}\n\n/**\n * Part 1 §3.3 / §7 — one concrete submission attempt for a Work Packet. A Dispatch Record\n * holds a run_id *set* (not a single run_id) tagged with its cardinality mode, so polling,\n * cancellation, and review packaging work the same way regardless of which Section 3.2\n * reading turns out to be correct.\n */\nexport interface DispatchRecord {\n\tattempt_n: number;\n\tcardinality_mode: CardinalityMode;\n\trun_ids: string[];\n\tsubmitted_at: string;\n\tmode: \"blocking\" | \"polling\";\n\tterminal_status?: string;\n\tterminal_at?: string;\n}\n\n/**\n * Part 1 §7 — one append-only entry in a Work Packet's transition log. Recorded for every\n * state change, including adjudication-call failures that have no `AdjudicationResult` to\n * archive elsewhere.\n */\nexport interface TransitionLogEntry {\n\tfrom: WorkPacketState;\n\tto: WorkPacketState;\n\tat: string;\n\tcause: string;\n}\n\n/**\n * Part 1 §1 / §7 — the Work Packet: the durable unit of intent this loop manages, potentially\n * resubmitted across several Dispatch Records over its life.\n *\n * The design doc (§7) also describes `adjudication_retry_count` (a separate bounded counter\n * for retrying the `adjudicate()` call itself, Part 1 §2/§6) and\n * `last_human_approved_topology_class` as persisted fields. Those are not modeled on this\n * type in this cut; a later change can add them without breaking the fields defined here.\n */\nexport interface WorkPacket {\n\tpacket_id: string;\n\tkind: string;\n\tcreated_at: string;\n\tpayload: unknown;\n\ttopology_decision: {\n\t\tclassification: TopologyClassification;\n\t\tdecided_at: string;\n\t\traw_route_response: unknown;\n\t} | null;\n\tdispatch_records: DispatchRecord[];\n\tstate: WorkPacketState;\n\tretry_count: number;\n\ttransition_log: TransitionLogEntry[];\n\tlast_adjudication_ref: string | null;\n\t/** Part 1 §4 — the per-packet attempt budget (`max_dispatch_attempts`) and how much of it has been used. */\n\tattempt_budget: {\n\t\tmax_dispatch_attempts: number;\n\t\tdispatch_attempts_used: number;\n\t};\n\t/**\n\t * Part 1 §2 state 3 / §7 — the payload most recently approved by a human reviewer (or the\n\t * original payload at creation, implicitly approved). `null` only if the packet has not yet\n\t * been assigned an initial baseline. Used by `requiresHumanApproval` to decide whether the\n\t * next attempt needs an AWAITING_APPROVAL gate before its first dispatch.\n\t */\n\tlast_human_approved_payload: unknown | null;\n}\n\n/**\n * Part 1 §4 — the named reasons the loop stops admitting new DRAFTED packets and begins\n * draining. `capacity_ceiling` and the cardinality-mismatch guard are soft governors (they\n * reduce admission/concurrency rather than terminating the loop outright); the others are\n * hard termination conditions.\n */\nexport type LoopTerminationCondition =\n\t| \"completion_exhaustion\"\n\t| \"per_packet_attempt_budget\"\n\t| \"wall_clock_budget\"\n\t| \"dispatch_call_budget\"\n\t| \"stagnation_guard\"\n\t| \"capacity_ceiling\"\n\t| \"external_abort\";\n\n/**\n * Part 1 §4 — loop-instance configuration. Per the \"Budget immutability\" rule in §4, every\n * field here is fixed at loop-instance creation and must not be mutated for that instance's\n * lifetime; raising a threshold requires starting a new loop instance.\n */\nexport interface LoopConfig {\n\tloop_instance_id: string;\n\t/** Part 1 §4 \"Per-packet attempt budget\" — illustrative default in the design doc is 3. */\n\tmax_dispatch_attempts_per_packet: number;\n\t/** Part 1 §4 \"Loop wall-clock budget\", expressed in milliseconds. */\n\tmax_loop_duration_ms: number;\n\t/** Part 1 §4 \"Loop dispatch-call budget\" — total `adaptorch_run` invocations allowed across the loop's life. */\n\tmax_total_dispatch_calls: number;\n\t/**\n\t * Part 1 §4 \"Stagnation guard\" — the number of consecutive loop-wide DECLINED verdicts\n\t * with indistinguishable evidence (same reason text / same evidence digest) that triggers\n\t * a halt.\n\t */\n\tstagnation_repeat_threshold: number;\n\t/**\n\t * Part 1 §4 \"Capacity ceiling (soft governor)\". Shape chosen for this implementation, not\n\t * dictated verbatim by the design doc: a saturation fraction/duration pair that must be\n\t * sustained before the governor engages, and the reduced concurrency ceiling it engages to.\n\t */\n\tcapacity_governor_thresholds: {\n\t\t/** Fraction (0-1) of `adaptorch_server_metrics` saturation considered \"sustained saturation\". */\n\t\tsaturation_threshold: number;\n\t\t/** How long saturation must persist, in milliseconds, before the governor engages. */\n\t\tsustained_duration_ms: number;\n\t\t/** Concurrency budget (max packets allowed into ACTIVE at once) while the governor is engaged. */\n\t\treduced_concurrency_ceiling: number;\n\t};\n\t/**\n\t * Part 1 §2 state 3 — the documented opt-in escape hatch that skips AWAITING_APPROVAL\n\t * for every attempt in this loop instance, regardless of payload/topology drift.\n\t */\n\tpre_approved_batch: boolean;\n\t/**\n\t * Part 1 §3.4 — the result of the one-time cardinality calibration probe, or `null` before\n\t * that probe has run. Continuously cross-checked (at zero extra call cost) against later\n\t * `adaptorch_get_run`/reconciliation-sweep observations per §3.4.\n\t */\n\tobserved_cardinality_mode: CardinalityMode | null;\n}\n\n/**\n * Part 1 §7 — on-disk file layout constants, rooted at a loop-instance directory. Exported so\n * other modules never hardcode these path segments.\n */\nexport const PACKETS_DIR = \"packets\";\nexport const PACKET_INDEX_FILE = \"packet_index.json\";\nexport const RUN_MAP_FILE = \"run_map.json\";\nexport const LOOP_STATE_FILE = \"loop_state.json\";\nexport const ADJUDICATIONS_DIR = \"adjudications\";\n"]}
package/dist/types.js CHANGED
@@ -4,6 +4,19 @@
4
4
  * and 7. It is an implementation of that document, not a restatement of it — see the design
5
5
  * doc for rationale, transition semantics, and the open questions left for other lanes.
6
6
  */
7
+ /** Current `adaptorch_route_topology` values, synchronized with AdaptOrch's `Topology` enum. */
8
+ export const TOPOLOGY_CLASSIFICATIONS = [
9
+ "parallel",
10
+ "sequential",
11
+ "hierarchical",
12
+ "hybrid",
13
+ "multi_model_ensemble",
14
+ "multi_turn_debate",
15
+ ];
16
+ const TOPOLOGY_CLASSIFICATION_SET = new Set(TOPOLOGY_CLASSIFICATIONS);
17
+ export function isTopologyClassification(value) {
18
+ return typeof value === "string" && TOPOLOGY_CLASSIFICATION_SET.has(value);
19
+ }
7
20
  /**
8
21
  * Part 1 §7 — on-disk file layout constants, rooted at a loop-instance directory. Exported so
9
22
  * other modules never hardcode these path segments.
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoKH;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC;AACrC,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AACrD,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAC3C,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AACjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC","sourcesContent":["/**\n * Design-fidelity note: this file implements the Work Packet on-disk schema and supporting\n * type vocabulary defined in Part 1 (`final-part1-core-algorithm.md`), Sections 1, 2, 3, 4,\n * and 7. It is an implementation of that document, not a restatement of it — see the design\n * doc for rationale, transition semantics, and the open questions left for other lanes.\n */\n\n/**\n * Work Packet lifecycle states.\n *\n * Part 1 §2 — the fourteen states of the packet-level state machine, including the\n * ESCALATED / AWAITING_APPROVAL / ADJUDICATION_FAILED additions from this revision.\n */\nexport type WorkPacketState =\n\t| \"DRAFTED\"\n\t| \"ROUTED\"\n\t| \"AWAITING_APPROVAL\"\n\t| \"DISPATCHED\"\n\t| \"ACTIVE\"\n\t| \"HALTING\"\n\t| \"RAW_TERMINAL\"\n\t| \"UNDER_REVIEW\"\n\t| \"ADJUDICATION_FAILED\"\n\t| \"CONFIRMED\"\n\t| \"DECLINED\"\n\t| \"RETRY_QUEUED\"\n\t| \"ESCALATED\"\n\t| \"CLOSED\";\n\n/**\n * Part 1 §3.3 — whether a Dispatch Record's run_id set was produced by a single\n * `adaptorch_run` call (`single_call`) or by N calls the loop itself issued (`fanout_n`).\n * This tag is what lets the rest of the state machine stay agnostic to the Section 3.2\n * single-call-vs-client-side-fanout ambiguity.\n */\nexport type CardinalityMode = \"single_call\" | \"fanout_n\";\n\n/**\n * Part 1 §3.1 the four topology classes `adaptorch_route_topology` can return for a\n * packet's payload, decided once per packet before any `adaptorch_run` call.\n */\nexport type TopologyClassification = \"singleton\" | \"pipeline\" | \"dag\" | \"ensemble\";\n\n/**\n * Part 1 §3.3 / §7 — one concrete submission attempt for a Work Packet. A Dispatch Record\n * holds a run_id *set* (not a single run_id) tagged with its cardinality mode, so polling,\n * cancellation, and review packaging work the same way regardless of which Section 3.2\n * reading turns out to be correct.\n */\nexport interface DispatchRecord {\n\tattempt_n: number;\n\tcardinality_mode: CardinalityMode;\n\trun_ids: string[];\n\tsubmitted_at: string;\n\tmode: \"blocking\" | \"polling\";\n\tterminal_status?: string;\n\tterminal_at?: string;\n}\n\n/**\n * Part 1 §7 — one append-only entry in a Work Packet's transition log. Recorded for every\n * state change, including adjudication-call failures that have no `AdjudicationResult` to\n * archive elsewhere.\n */\nexport interface TransitionLogEntry {\n\tfrom: WorkPacketState;\n\tto: WorkPacketState;\n\tat: string;\n\tcause: string;\n}\n\n/**\n * Part 1 §1 / §7 — the Work Packet: the durable unit of intent this loop manages, potentially\n * resubmitted across several Dispatch Records over its life.\n *\n * The design doc (§7) also describes `adjudication_retry_count` (a separate bounded counter\n * for retrying the `adjudicate()` call itself, Part 1 §2/§6) and\n * `last_human_approved_topology_class` as persisted fields. Those are not modeled on this\n * type in this cut; a later change can add them without breaking the fields defined here.\n */\nexport interface WorkPacket {\n\tpacket_id: string;\n\tkind: string;\n\tcreated_at: string;\n\tpayload: unknown;\n\ttopology_decision: {\n\t\tclassification: TopologyClassification;\n\t\tdecided_at: string;\n\t\traw_route_response: unknown;\n\t} | null;\n\tdispatch_records: DispatchRecord[];\n\tstate: WorkPacketState;\n\tretry_count: number;\n\ttransition_log: TransitionLogEntry[];\n\tlast_adjudication_ref: string | null;\n\t/** Part 1 §4 — the per-packet attempt budget (`max_dispatch_attempts`) and how much of it has been used. */\n\tattempt_budget: {\n\t\tmax_dispatch_attempts: number;\n\t\tdispatch_attempts_used: number;\n\t};\n\t/**\n\t * Part 1 §2 state 3 / §7 — the payload most recently approved by a human reviewer (or the\n\t * original payload at creation, implicitly approved). `null` only if the packet has not yet\n\t * been assigned an initial baseline. Used by `requiresHumanApproval` to decide whether the\n\t * next attempt needs an AWAITING_APPROVAL gate before its first dispatch.\n\t */\n\tlast_human_approved_payload: unknown | null;\n}\n\n/**\n * Part 1 §4 — the named reasons the loop stops admitting new DRAFTED packets and begins\n * draining. `capacity_ceiling` and the cardinality-mismatch guard are soft governors (they\n * reduce admission/concurrency rather than terminating the loop outright); the others are\n * hard termination conditions.\n */\nexport type LoopTerminationCondition =\n\t| \"completion_exhaustion\"\n\t| \"per_packet_attempt_budget\"\n\t| \"wall_clock_budget\"\n\t| \"dispatch_call_budget\"\n\t| \"stagnation_guard\"\n\t| \"capacity_ceiling\"\n\t| \"external_abort\";\n\n/**\n * Part 1 §4 — loop-instance configuration. Per the \"Budget immutability\" rule in §4, every\n * field here is fixed at loop-instance creation and must not be mutated for that instance's\n * lifetime; raising a threshold requires starting a new loop instance.\n */\nexport interface LoopConfig {\n\tloop_instance_id: string;\n\t/** Part 1 §4 \"Per-packet attempt budget\" — illustrative default in the design doc is 3. */\n\tmax_dispatch_attempts_per_packet: number;\n\t/** Part 1 §4 \"Loop wall-clock budget\", expressed in milliseconds. */\n\tmax_loop_duration_ms: number;\n\t/** Part 1 §4 \"Loop dispatch-call budget\" — total `adaptorch_run` invocations allowed across the loop's life. */\n\tmax_total_dispatch_calls: number;\n\t/**\n\t * Part 1 §4 \"Stagnation guard\" — the number of consecutive loop-wide DECLINED verdicts\n\t * with indistinguishable evidence (same reason text / same evidence digest) that triggers\n\t * a halt.\n\t */\n\tstagnation_repeat_threshold: number;\n\t/**\n\t * Part 1 §4 \"Capacity ceiling (soft governor)\". Shape chosen for this implementation, not\n\t * dictated verbatim by the design doc: a saturation fraction/duration pair that must be\n\t * sustained before the governor engages, and the reduced concurrency ceiling it engages to.\n\t */\n\tcapacity_governor_thresholds: {\n\t\t/** Fraction (0-1) of `adaptorch_server_metrics` saturation considered \"sustained saturation\". */\n\t\tsaturation_threshold: number;\n\t\t/** How long saturation must persist, in milliseconds, before the governor engages. */\n\t\tsustained_duration_ms: number;\n\t\t/** Concurrency budget (max packets allowed into ACTIVE at once) while the governor is engaged. */\n\t\treduced_concurrency_ceiling: number;\n\t};\n\t/**\n\t * Part 1 §2 state 3 — the documented opt-in escape hatch that skips AWAITING_APPROVAL\n\t * for every attempt in this loop instance, regardless of payload/topology drift.\n\t */\n\tpre_approved_batch: boolean;\n\t/**\n\t * Part 1 §3.4 — the result of the one-time cardinality calibration probe, or `null` before\n\t * that probe has run. Continuously cross-checked (at zero extra call cost) against later\n\t * `adaptorch_get_run`/reconciliation-sweep observations per §3.4.\n\t */\n\tobserved_cardinality_mode: CardinalityMode | null;\n}\n\n/**\n * Part 1 §7 — on-disk file layout constants, rooted at a loop-instance directory. Exported so\n * other modules never hardcode these path segments.\n */\nexport const PACKETS_DIR = \"packets\";\nexport const PACKET_INDEX_FILE = \"packet_index.json\";\nexport const RUN_MAP_FILE = \"run_map.json\";\nexport const LOOP_STATE_FILE = \"loop_state.json\";\nexport const ADJUDICATIONS_DIR = \"adjudications\";\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgCH,gGAAgG;AAChG,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACvC,UAAU;IACV,YAAY;IACZ,cAAc;IACd,QAAQ;IACR,sBAAsB;IACtB,mBAAmB;CACV,CAAC;AAIX,MAAM,2BAA2B,GAAwB,IAAI,GAAG,CAAC,wBAAwB,CAAC,CAAC;AAE3F,MAAM,UAAU,wBAAwB,CAAC,KAAc,EAAmC;IACzF,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,2BAA2B,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAAA,CAC3E;AAgID;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC;AACrC,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AACrD,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAC3C,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AACjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC","sourcesContent":["/**\n * Design-fidelity note: this file implements the Work Packet on-disk schema and supporting\n * type vocabulary defined in Part 1 (`final-part1-core-algorithm.md`), Sections 1, 2, 3, 4,\n * and 7. It is an implementation of that document, not a restatement of it — see the design\n * doc for rationale, transition semantics, and the open questions left for other lanes.\n */\n\n/**\n * Work Packet lifecycle states.\n *\n * Part 1 §2 — the fourteen states of the packet-level state machine, including the\n * ESCALATED / AWAITING_APPROVAL / ADJUDICATION_FAILED additions from this revision.\n */\nexport type WorkPacketState =\n\t| \"DRAFTED\"\n\t| \"ROUTED\"\n\t| \"AWAITING_APPROVAL\"\n\t| \"DISPATCHED\"\n\t| \"ACTIVE\"\n\t| \"HALTING\"\n\t| \"RAW_TERMINAL\"\n\t| \"UNDER_REVIEW\"\n\t| \"ADJUDICATION_FAILED\"\n\t| \"CONFIRMED\"\n\t| \"DECLINED\"\n\t| \"RETRY_QUEUED\"\n\t| \"ESCALATED\"\n\t| \"CLOSED\";\n\n/**\n * Part 1 §3.3 — whether a Dispatch Record's run_id set was produced by a single\n * `adaptorch_run` call (`single_call`) or by N calls the loop itself issued (`fanout_n`).\n * This tag is what lets the rest of the state machine stay agnostic to the Section 3.2\n * single-call-vs-client-side-fanout ambiguity.\n */\nexport type CardinalityMode = \"single_call\" | \"fanout_n\";\n\n/** Current `adaptorch_route_topology` values, synchronized with AdaptOrch's `Topology` enum. */\nexport const TOPOLOGY_CLASSIFICATIONS = [\n\t\"parallel\",\n\t\"sequential\",\n\t\"hierarchical\",\n\t\"hybrid\",\n\t\"multi_model_ensemble\",\n\t\"multi_turn_debate\",\n] as const;\n\nexport type TopologyClassification = (typeof TOPOLOGY_CLASSIFICATIONS)[number];\n\nconst TOPOLOGY_CLASSIFICATION_SET: ReadonlySet<string> = new Set(TOPOLOGY_CLASSIFICATIONS);\n\nexport function isTopologyClassification(value: unknown): value is TopologyClassification {\n\treturn typeof value === \"string\" && TOPOLOGY_CLASSIFICATION_SET.has(value);\n}\n\n/**\n * Part 1 §3.3 / §7 — one concrete submission attempt for a Work Packet. A Dispatch Record\n * holds a run_id *set* (not a single run_id) tagged with its cardinality mode, so polling,\n * cancellation, and review packaging work the same way regardless of which Section 3.2\n * reading turns out to be correct.\n */\nexport interface DispatchRecord {\n\tattempt_n: number;\n\tcardinality_mode: CardinalityMode;\n\trun_ids: string[];\n\tsubmitted_at: string;\n\tmode: \"blocking\" | \"polling\";\n\tterminal_status?: string;\n\tterminal_at?: string;\n}\n\n/**\n * Part 1 §7 — one append-only entry in a Work Packet's transition log. Recorded for every\n * state change, including adjudication-call failures that have no `AdjudicationResult` to\n * archive elsewhere.\n */\nexport interface TransitionLogEntry {\n\tfrom: WorkPacketState;\n\tto: WorkPacketState;\n\tat: string;\n\tcause: string;\n}\n\n/**\n * Part 1 §1 / §7 — the Work Packet: the durable unit of intent this loop manages, potentially\n * resubmitted across several Dispatch Records over its life.\n *\n * The design doc (§7) also describes `adjudication_retry_count` (a separate bounded counter\n * for retrying the `adjudicate()` call itself, Part 1 §2/§6) and\n * `last_human_approved_topology_class` as persisted fields. Those are not modeled on this\n * type in this cut; a later change can add them without breaking the fields defined here.\n */\nexport interface WorkPacket {\n\tpacket_id: string;\n\tkind: string;\n\tcreated_at: string;\n\tpayload: unknown;\n\ttopology_decision: {\n\t\tclassification: TopologyClassification;\n\t\tdecided_at: string;\n\t\traw_route_response: unknown;\n\t} | null;\n\tdispatch_records: DispatchRecord[];\n\tstate: WorkPacketState;\n\tretry_count: number;\n\ttransition_log: TransitionLogEntry[];\n\tlast_adjudication_ref: string | null;\n\t/** Part 1 §4 — the per-packet attempt budget (`max_dispatch_attempts`) and how much of it has been used. */\n\tattempt_budget: {\n\t\tmax_dispatch_attempts: number;\n\t\tdispatch_attempts_used: number;\n\t};\n\t/**\n\t * Part 1 §2 state 3 / §7 — the payload most recently approved by a human reviewer (or the\n\t * original payload at creation, implicitly approved). `null` only if the packet has not yet\n\t * been assigned an initial baseline. Used by `requiresHumanApproval` to decide whether the\n\t * next attempt needs an AWAITING_APPROVAL gate before its first dispatch.\n\t */\n\tlast_human_approved_payload: unknown | null;\n}\n\n/**\n * Part 1 §4 — the named reasons the loop stops admitting new DRAFTED packets and begins\n * draining. `capacity_ceiling` and the cardinality-mismatch guard are soft governors (they\n * reduce admission/concurrency rather than terminating the loop outright); the others are\n * hard termination conditions.\n */\nexport type LoopTerminationCondition =\n\t| \"completion_exhaustion\"\n\t| \"per_packet_attempt_budget\"\n\t| \"wall_clock_budget\"\n\t| \"dispatch_call_budget\"\n\t| \"stagnation_guard\"\n\t| \"capacity_ceiling\"\n\t| \"external_abort\";\n\n/**\n * Part 1 §4 — loop-instance configuration. Per the \"Budget immutability\" rule in §4, every\n * field here is fixed at loop-instance creation and must not be mutated for that instance's\n * lifetime; raising a threshold requires starting a new loop instance.\n */\nexport interface LoopConfig {\n\tloop_instance_id: string;\n\t/** Part 1 §4 \"Per-packet attempt budget\" — illustrative default in the design doc is 3. */\n\tmax_dispatch_attempts_per_packet: number;\n\t/** Part 1 §4 \"Loop wall-clock budget\", expressed in milliseconds. */\n\tmax_loop_duration_ms: number;\n\t/** Part 1 §4 \"Loop dispatch-call budget\" — total `adaptorch_run` invocations allowed across the loop's life. */\n\tmax_total_dispatch_calls: number;\n\t/**\n\t * Part 1 §4 \"Stagnation guard\" — the number of consecutive loop-wide DECLINED verdicts\n\t * with indistinguishable evidence (same reason text / same evidence digest) that triggers\n\t * a halt.\n\t */\n\tstagnation_repeat_threshold: number;\n\t/**\n\t * Part 1 §4 \"Capacity ceiling (soft governor)\". Shape chosen for this implementation, not\n\t * dictated verbatim by the design doc: a saturation fraction/duration pair that must be\n\t * sustained before the governor engages, and the reduced concurrency ceiling it engages to.\n\t */\n\tcapacity_governor_thresholds: {\n\t\t/** Fraction (0-1) of `adaptorch_server_metrics` saturation considered \"sustained saturation\". */\n\t\tsaturation_threshold: number;\n\t\t/** How long saturation must persist, in milliseconds, before the governor engages. */\n\t\tsustained_duration_ms: number;\n\t\t/** Concurrency budget (max packets allowed into ACTIVE at once) while the governor is engaged. */\n\t\treduced_concurrency_ceiling: number;\n\t};\n\t/**\n\t * Part 1 §2 state 3 — the documented opt-in escape hatch that skips AWAITING_APPROVAL\n\t * for every attempt in this loop instance, regardless of payload/topology drift.\n\t */\n\tpre_approved_batch: boolean;\n\t/**\n\t * Part 1 §3.4 — the result of the one-time cardinality calibration probe, or `null` before\n\t * that probe has run. Continuously cross-checked (at zero extra call cost) against later\n\t * `adaptorch_get_run`/reconciliation-sweep observations per §3.4.\n\t */\n\tobserved_cardinality_mode: CardinalityMode | null;\n}\n\n/**\n * Part 1 §7 — on-disk file layout constants, rooted at a loop-instance directory. Exported so\n * other modules never hardcode these path segments.\n */\nexport const PACKETS_DIR = \"packets\";\nexport const PACKET_INDEX_FILE = \"packet_index.json\";\nexport const RUN_MAP_FILE = \"run_map.json\";\nexport const LOOP_STATE_FILE = \"loop_state.json\";\nexport const ADJUDICATIONS_DIR = \"adjudications\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omk-adaptorch-wpl",
3
- "version": "0.96.2",
3
+ "version": "0.97.0",
4
4
  "description": "AdaptOrch-native Work Packet Loop (WPL) — state machine, verification layer, and integration bridge for OMK orchestration.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",