omk-adaptorch-wpl 0.91.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.
- package/README.md +49 -0
- package/dist/adaptorch-client.d.ts +184 -0
- package/dist/adaptorch-client.d.ts.map +1 -0
- package/dist/adaptorch-client.js +109 -0
- package/dist/adaptorch-client.js.map +1 -0
- package/dist/adjudicator-registry.d.ts +93 -0
- package/dist/adjudicator-registry.d.ts.map +1 -0
- package/dist/adjudicator-registry.js +89 -0
- package/dist/adjudicator-registry.js.map +1 -0
- package/dist/adjudicator.d.ts +73 -0
- package/dist/adjudicator.d.ts.map +1 -0
- package/dist/adjudicator.js +356 -0
- package/dist/adjudicator.js.map +1 -0
- package/dist/b2c-mapper.d.ts +25 -0
- package/dist/b2c-mapper.d.ts.map +1 -0
- package/dist/b2c-mapper.js +186 -0
- package/dist/b2c-mapper.js.map +1 -0
- package/dist/b2c-verdict.d.ts +66 -0
- package/dist/b2c-verdict.d.ts.map +1 -0
- package/dist/b2c-verdict.js +5 -0
- package/dist/b2c-verdict.js.map +1 -0
- package/dist/deep-wall.d.ts +80 -0
- package/dist/deep-wall.d.ts.map +1 -0
- package/dist/deep-wall.js +97 -0
- package/dist/deep-wall.js.map +1 -0
- package/dist/evaluate-correctness-wall.d.ts +35 -0
- package/dist/evaluate-correctness-wall.d.ts.map +1 -0
- package/dist/evaluate-correctness-wall.js +128 -0
- package/dist/evaluate-correctness-wall.js.map +1 -0
- package/dist/in-memory-adaptorch.d.ts +12 -0
- package/dist/in-memory-adaptorch.d.ts.map +1 -0
- package/dist/in-memory-adaptorch.js +26 -0
- package/dist/in-memory-adaptorch.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/live-adaptorch-transport.d.ts +14 -0
- package/dist/live-adaptorch-transport.d.ts.map +1 -0
- package/dist/live-adaptorch-transport.js +19 -0
- package/dist/live-adaptorch-transport.js.map +1 -0
- package/dist/loop.d.ts +149 -0
- package/dist/loop.d.ts.map +1 -0
- package/dist/loop.js +219 -0
- package/dist/loop.js.map +1 -0
- package/dist/mcp-introspection-transport.d.ts +18 -0
- package/dist/mcp-introspection-transport.d.ts.map +1 -0
- package/dist/mcp-introspection-transport.js +29 -0
- package/dist/mcp-introspection-transport.js.map +1 -0
- package/dist/policy-wall.d.ts +34 -0
- package/dist/policy-wall.d.ts.map +1 -0
- package/dist/policy-wall.js +125 -0
- package/dist/policy-wall.js.map +1 -0
- package/dist/receipt-signature.d.ts +28 -0
- package/dist/receipt-signature.d.ts.map +1 -0
- package/dist/receipt-signature.js +30 -0
- package/dist/receipt-signature.js.map +1 -0
- package/dist/regenerate-packet.d.ts +25 -0
- package/dist/regenerate-packet.d.ts.map +1 -0
- package/dist/regenerate-packet.js +29 -0
- package/dist/regenerate-packet.js.map +1 -0
- package/dist/repair-budget.d.ts +24 -0
- package/dist/repair-budget.d.ts.map +1 -0
- package/dist/repair-budget.js +44 -0
- package/dist/repair-budget.js.map +1 -0
- package/dist/repair-loop.d.ts +18 -0
- package/dist/repair-loop.d.ts.map +1 -0
- package/dist/repair-loop.js +54 -0
- package/dist/repair-loop.js.map +1 -0
- package/dist/retry-backoff.d.ts +56 -0
- package/dist/retry-backoff.d.ts.map +1 -0
- package/dist/retry-backoff.js +75 -0
- package/dist/retry-backoff.js.map +1 -0
- package/dist/signed-receipt.d.ts +29 -0
- package/dist/signed-receipt.d.ts.map +1 -0
- package/dist/signed-receipt.js +25 -0
- package/dist/signed-receipt.js.map +1 -0
- package/dist/state-machine.d.ts +40 -0
- package/dist/state-machine.d.ts.map +1 -0
- package/dist/state-machine.js +88 -0
- package/dist/state-machine.js.map +1 -0
- package/dist/types.d.ts +149 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/dist/wall-meta.d.ts +3 -0
- package/dist/wall-meta.d.ts.map +1 -0
- package/dist/wall-meta.js +3 -0
- package/dist/wall-meta.js.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# omk-adaptorch-wpl
|
|
2
|
+
|
|
3
|
+
> **Status**: Stable (v0.90.9). Wired into `open-multi-agent-kit` as a workspace dependency.
|
|
4
|
+
> This package implements the AdaptOrch-native Work Packet Loop (WPL) design, an original
|
|
5
|
+
> execution loop whose only work-producing action is AdaptOrch's `adaptorch_run` tool. See
|
|
6
|
+
> [AdaptOrch](https://adaptorch.com) for the backend product this integrates with; AdaptOrch is
|
|
7
|
+
> still under active development and this integration currently targets its free **Start** tier.
|
|
8
|
+
|
|
9
|
+
## Design documents
|
|
10
|
+
|
|
11
|
+
The full design (state machine, verification layer, integration mapping, and the adversarial
|
|
12
|
+
review that shaped the safety gates below) lives outside this package at
|
|
13
|
+
`.omk/runs/adaptorch-native-loop-algorithm-20260701/`:
|
|
14
|
+
|
|
15
|
+
- `final-part1-core-algorithm.md` — Work Packet state machine, termination conditions, cancellation policy
|
|
16
|
+
- `final-part2-verification-layer.md` — the Outcome Adjudicator (5-state verification)
|
|
17
|
+
- `final-part3-integration.md` — the projection/bridge between the two
|
|
18
|
+
|
|
19
|
+
## Modules
|
|
20
|
+
|
|
21
|
+
- `src/types.ts` — Work Packet, Dispatch Record, state enums (as string literal unions), on-disk schema types
|
|
22
|
+
- `src/state-machine.ts` — the packet lifecycle state machine and transition guards
|
|
23
|
+
- `src/adaptorch-client.ts` — thin typed wrapper around AdaptOrch's 10 MCP tools
|
|
24
|
+
- `src/adjudicator.ts` + `src/adjudicator-registry.ts` — the Outcome Adjudicator and its per-`kind` registry
|
|
25
|
+
- `src/loop.ts` — the integration layer wiring the state machine, AdaptOrch client, and adjudicator together
|
|
26
|
+
- `src/b2c-mapper.ts` — B2C (Bridge-to-Code) mapping for patch-apply safety
|
|
27
|
+
- `src/b2c-verdict.ts` — Verdict card schema for correctness wall decisions
|
|
28
|
+
- `src/deep-wall.ts` — Deep verification wall for multi-runner evidence gating
|
|
29
|
+
- `src/receipt-signature.ts` — Cryptographic receipt signing for verification evidence
|
|
30
|
+
|
|
31
|
+
## Integration
|
|
32
|
+
|
|
33
|
+
The coding-agent consumes this package via:
|
|
34
|
+
|
|
35
|
+
- `packages/coding-agent/src/core/adaptorch-bridge.ts` — advisory-only bridge (default-off,
|
|
36
|
+
circuit-breaker protected, TTL-cached). Provides `getFreshHint` (sync, cache-read-only) and
|
|
37
|
+
`requestRefresh` (fire-and-forget) for the reasoning router's turn-start path.
|
|
38
|
+
- `packages/coding-agent/docs/adaptorch-preview.md` — read-first planning pipeline spec.
|
|
39
|
+
|
|
40
|
+
## Safety notes (do not remove without updating the design docs)
|
|
41
|
+
|
|
42
|
+
- `ESCALATED` packets never resume automatically; only an explicit external unblock signal moves them on.
|
|
43
|
+
- The first Dispatch Record of any payload that differs from the last human-approved baseline
|
|
44
|
+
(an `augmented_payload` was applied, or a `REROUTE` changed topology) requires human approval
|
|
45
|
+
(`AWAITING_APPROVAL`), unless the loop is explicitly launched in pre-approved-batch mode.
|
|
46
|
+
- Loop-level budgets (`max_dispatch_attempts`, `max_loop_duration`, dispatch-call budget) are
|
|
47
|
+
immutable for a loop instance's lifetime; raising them requires a new instance under the same review.
|
|
48
|
+
|
|
49
|
+
Preview spec: [`../coding-agent/docs/adaptorch-preview.md`](../coding-agent/docs/adaptorch-preview.md)
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AdaptOrch MCP client wrapper.
|
|
3
|
+
*
|
|
4
|
+
* Design-stage / experimental: this module has no production
|
|
5
|
+
* `AdaptOrchTransport` implementation wired in yet. Callers must supply
|
|
6
|
+
* their own transport (e.g. an adapter around an MCP SDK client) until one
|
|
7
|
+
* ships in this package.
|
|
8
|
+
*
|
|
9
|
+
* Tool surface, names, and read/write classification are grounded in
|
|
10
|
+
* `.omk/runs/lazycodex-adaptorch-loop-plan-20260701/lane2-adaptorch-tool-surface.md`,
|
|
11
|
+
* which cross-checks the real AdaptOrch MCP server against
|
|
12
|
+
* `docs/tools.md`, `README.md`, `mcp_server.py` dispatch, and
|
|
13
|
+
* `diagnostics.py::EXPECTED_CORE_TOOLS`. There are exactly 10 real tools;
|
|
14
|
+
* no "benchmark" or "verification" tools exist in the shipped surface.
|
|
15
|
+
*/
|
|
16
|
+
import type { TopologyClassification } from "./types.ts";
|
|
17
|
+
/**
|
|
18
|
+
* Abstract transport for invoking AdaptOrch MCP tools by name.
|
|
19
|
+
*
|
|
20
|
+
* See doc section "The real, current 10-tool MCP surface (grouped)". No
|
|
21
|
+
* concrete implementation ships with this package yet; a caller must
|
|
22
|
+
* provide one (e.g. wrapping an MCP SDK client's `callTool`).
|
|
23
|
+
*/
|
|
24
|
+
export interface AdaptOrchTransport {
|
|
25
|
+
callTool(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Payload accepted by `adaptorch_run`.
|
|
29
|
+
*
|
|
30
|
+
* See doc section "Run / lifecycle (submit, inspect, list, cancel)":
|
|
31
|
+
* `adaptorch_run` submits a task payload (prompt/context/raw payload,
|
|
32
|
+
* connector, synthesis mode, budget policy) to the control-plane, and can
|
|
33
|
+
* optionally block until the run reaches a terminal status.
|
|
34
|
+
*/
|
|
35
|
+
export interface AdaptOrchRunPayload {
|
|
36
|
+
taskPayload: unknown;
|
|
37
|
+
connector?: string;
|
|
38
|
+
synthesisMode?: string;
|
|
39
|
+
budgetPolicy?: unknown;
|
|
40
|
+
waitForTerminal?: boolean;
|
|
41
|
+
timeoutSeconds?: number;
|
|
42
|
+
pollIntervalSeconds?: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Result of `adaptorch_run`.
|
|
46
|
+
*
|
|
47
|
+
* Shape is inferred from the doc's description of the tool's purpose, not
|
|
48
|
+
* guaranteed by an official schema.
|
|
49
|
+
*/
|
|
50
|
+
export interface AdaptOrchRunResult {
|
|
51
|
+
run_id: string;
|
|
52
|
+
status?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Result of `adaptorch_get_run`.
|
|
56
|
+
*
|
|
57
|
+
* Shape is inferred from the doc's description ("fetch a run summary by
|
|
58
|
+
* run_id"), not guaranteed by an official schema; extra fields are
|
|
59
|
+
* expected to vary by connector/synthesis mode.
|
|
60
|
+
*/
|
|
61
|
+
export interface AdaptOrchRunSummary {
|
|
62
|
+
run_id: string;
|
|
63
|
+
status: string;
|
|
64
|
+
[key: string]: unknown;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Entry in the result of `adaptorch_list_runs`.
|
|
68
|
+
*
|
|
69
|
+
* Shape is inferred, not guaranteed by an official schema.
|
|
70
|
+
*/
|
|
71
|
+
export interface AdaptOrchRunListEntry {
|
|
72
|
+
run_id: string;
|
|
73
|
+
status: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Result of `adaptorch_cancel_run`.
|
|
77
|
+
*
|
|
78
|
+
* Shape is inferred from the doc's description ("request cancellation of
|
|
79
|
+
* an in-flight run by run_id"), not guaranteed by an official schema.
|
|
80
|
+
*/
|
|
81
|
+
export interface AdaptOrchCancelResult {
|
|
82
|
+
run_id: string;
|
|
83
|
+
cancelled: boolean;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Entry in the result of `adaptorch_get_artifacts`.
|
|
87
|
+
*
|
|
88
|
+
* Shape is inferred from the doc's description ("fetch artifact metadata
|
|
89
|
+
* for a run"), not guaranteed by an official schema.
|
|
90
|
+
*/
|
|
91
|
+
export interface AdaptOrchArtifact {
|
|
92
|
+
path: string;
|
|
93
|
+
size_bytes?: number;
|
|
94
|
+
created_at?: string;
|
|
95
|
+
[key: string]: unknown;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Entry in the result of `adaptorch_get_traces`.
|
|
99
|
+
*
|
|
100
|
+
* Shape is inferred from the doc's description ("fetch execution traces
|
|
101
|
+
* for a run by run_id"), not guaranteed by an official schema.
|
|
102
|
+
*/
|
|
103
|
+
export interface AdaptOrchTraceSpan {
|
|
104
|
+
span_id?: string;
|
|
105
|
+
kind?: string;
|
|
106
|
+
severity?: string;
|
|
107
|
+
[key: string]: unknown;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Result of `adaptorch_route_topology`.
|
|
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.
|
|
116
|
+
*/
|
|
117
|
+
export interface AdaptOrchRouteTopologyResult {
|
|
118
|
+
classification: TopologyClassification;
|
|
119
|
+
raw: unknown;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Typed wrapper around the 10 real AdaptOrch MCP tools.
|
|
123
|
+
*
|
|
124
|
+
* See doc section "The real, current 10-tool MCP surface (grouped)" for
|
|
125
|
+
* the full tool list, purposes, and read/write classification. This
|
|
126
|
+
* class only translates method calls into `transport.callTool` calls
|
|
127
|
+
* with the exact tool names the doc lists; it does not implement a
|
|
128
|
+
* transport itself.
|
|
129
|
+
*/
|
|
130
|
+
export declare class AdaptOrchClient {
|
|
131
|
+
private readonly transport;
|
|
132
|
+
constructor(transport: AdaptOrchTransport);
|
|
133
|
+
/**
|
|
134
|
+
* `adaptorch_run` (write). Submit a task payload to the control-plane,
|
|
135
|
+
* optionally blocking until the run reaches a terminal status.
|
|
136
|
+
*/
|
|
137
|
+
run(payload: AdaptOrchRunPayload): Promise<AdaptOrchRunResult>;
|
|
138
|
+
/**
|
|
139
|
+
* `adaptorch_get_run` (read). Fetch a run summary by `run_id`.
|
|
140
|
+
*/
|
|
141
|
+
getRun(runId: string): Promise<AdaptOrchRunSummary>;
|
|
142
|
+
/**
|
|
143
|
+
* `adaptorch_list_runs` (read). List recent control-plane runs.
|
|
144
|
+
*/
|
|
145
|
+
listRuns(params?: {
|
|
146
|
+
limit?: number;
|
|
147
|
+
}): Promise<AdaptOrchRunListEntry[]>;
|
|
148
|
+
/**
|
|
149
|
+
* `adaptorch_cancel_run` (write). Request cancellation of an in-flight
|
|
150
|
+
* run by `run_id`.
|
|
151
|
+
*/
|
|
152
|
+
cancelRun(runId: string): Promise<AdaptOrchCancelResult>;
|
|
153
|
+
/**
|
|
154
|
+
* `adaptorch_get_artifacts` (read). Fetch artifact metadata for a run.
|
|
155
|
+
*/
|
|
156
|
+
getArtifacts(runId: string): Promise<AdaptOrchArtifact[]>;
|
|
157
|
+
/**
|
|
158
|
+
* `adaptorch_get_traces` (read). Fetch execution traces for a run by
|
|
159
|
+
* `run_id`.
|
|
160
|
+
*/
|
|
161
|
+
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
|
+
*/
|
|
167
|
+
routeTopology(payloadShape: unknown): Promise<AdaptOrchRouteTopologyResult>;
|
|
168
|
+
/**
|
|
169
|
+
* `adaptorch_server_metrics` (read/local). Read redacted MCP server
|
|
170
|
+
* metrics (tool-call counters, latency percentiles).
|
|
171
|
+
*/
|
|
172
|
+
serverMetrics(): Promise<Record<string, unknown>>;
|
|
173
|
+
/**
|
|
174
|
+
* `adaptorch_capabilities` (read/local). Read supported synthesis
|
|
175
|
+
* modes, connectors, and server features.
|
|
176
|
+
*/
|
|
177
|
+
capabilities(): Promise<Record<string, unknown>>;
|
|
178
|
+
/**
|
|
179
|
+
* `adaptorch_plan_catalog` (read/local). Read the hosted plan catalog
|
|
180
|
+
* (Starter $0 / Pro $39 / Team $149).
|
|
181
|
+
*/
|
|
182
|
+
planCatalog(): Promise<Record<string, unknown>>;
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=adaptorch-client.d.ts.map
|
|
@@ -0,0 +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,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACxE;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IACnC,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,4BAA4B;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;;;;OAIG;IACG,aAAa,CAAC,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAShF;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 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"]}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AdaptOrch MCP client wrapper.
|
|
3
|
+
*
|
|
4
|
+
* Design-stage / experimental: this module has no production
|
|
5
|
+
* `AdaptOrchTransport` implementation wired in yet. Callers must supply
|
|
6
|
+
* their own transport (e.g. an adapter around an MCP SDK client) until one
|
|
7
|
+
* ships in this package.
|
|
8
|
+
*
|
|
9
|
+
* Tool surface, names, and read/write classification are grounded in
|
|
10
|
+
* `.omk/runs/lazycodex-adaptorch-loop-plan-20260701/lane2-adaptorch-tool-surface.md`,
|
|
11
|
+
* which cross-checks the real AdaptOrch MCP server against
|
|
12
|
+
* `docs/tools.md`, `README.md`, `mcp_server.py` dispatch, and
|
|
13
|
+
* `diagnostics.py::EXPECTED_CORE_TOOLS`. There are exactly 10 real tools;
|
|
14
|
+
* no "benchmark" or "verification" tools exist in the shipped surface.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Typed wrapper around the 10 real AdaptOrch MCP tools.
|
|
18
|
+
*
|
|
19
|
+
* See doc section "The real, current 10-tool MCP surface (grouped)" for
|
|
20
|
+
* the full tool list, purposes, and read/write classification. This
|
|
21
|
+
* class only translates method calls into `transport.callTool` calls
|
|
22
|
+
* with the exact tool names the doc lists; it does not implement a
|
|
23
|
+
* transport itself.
|
|
24
|
+
*/
|
|
25
|
+
export class AdaptOrchClient {
|
|
26
|
+
transport;
|
|
27
|
+
constructor(transport) {
|
|
28
|
+
this.transport = transport;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* `adaptorch_run` (write). Submit a task payload to the control-plane,
|
|
32
|
+
* optionally blocking until the run reaches a terminal status.
|
|
33
|
+
*/
|
|
34
|
+
async run(payload) {
|
|
35
|
+
// The transport result shape is not schema-validated here; callers
|
|
36
|
+
// relying on strict correctness should validate at the transport
|
|
37
|
+
// boundary.
|
|
38
|
+
return (await this.transport.callTool("adaptorch_run", { ...payload }));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* `adaptorch_get_run` (read). Fetch a run summary by `run_id`.
|
|
42
|
+
*/
|
|
43
|
+
async getRun(runId) {
|
|
44
|
+
return (await this.transport.callTool("adaptorch_get_run", { run_id: runId }));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* `adaptorch_list_runs` (read). List recent control-plane runs.
|
|
48
|
+
*/
|
|
49
|
+
async listRuns(params) {
|
|
50
|
+
return (await this.transport.callTool("adaptorch_list_runs", { ...params }));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* `adaptorch_cancel_run` (write). Request cancellation of an in-flight
|
|
54
|
+
* run by `run_id`.
|
|
55
|
+
*/
|
|
56
|
+
async cancelRun(runId) {
|
|
57
|
+
return (await this.transport.callTool("adaptorch_cancel_run", { run_id: runId }));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* `adaptorch_get_artifacts` (read). Fetch artifact metadata for a run.
|
|
61
|
+
*/
|
|
62
|
+
async getArtifacts(runId) {
|
|
63
|
+
return (await this.transport.callTool("adaptorch_get_artifacts", { run_id: runId }));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* `adaptorch_get_traces` (read). Fetch execution traces for a run by
|
|
67
|
+
* `run_id`.
|
|
68
|
+
*/
|
|
69
|
+
async getTraces(runId) {
|
|
70
|
+
return (await this.transport.callTool("adaptorch_get_traces", { run_id: runId }));
|
|
71
|
+
}
|
|
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
|
+
*/
|
|
77
|
+
async routeTopology(payloadShape) {
|
|
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
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* `adaptorch_server_metrics` (read/local). Read redacted MCP server
|
|
89
|
+
* metrics (tool-call counters, latency percentiles).
|
|
90
|
+
*/
|
|
91
|
+
async serverMetrics() {
|
|
92
|
+
return (await this.transport.callTool("adaptorch_server_metrics", {}));
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* `adaptorch_capabilities` (read/local). Read supported synthesis
|
|
96
|
+
* modes, connectors, and server features.
|
|
97
|
+
*/
|
|
98
|
+
async capabilities() {
|
|
99
|
+
return (await this.transport.callTool("adaptorch_capabilities", {}));
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* `adaptorch_plan_catalog` (read/local). Read the hosted plan catalog
|
|
103
|
+
* (Starter $0 / Pro $39 / Team $149).
|
|
104
|
+
*/
|
|
105
|
+
async planCatalog() {
|
|
106
|
+
return (await this.transport.callTool("adaptorch_plan_catalog", {}));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=adaptorch-client.js.map
|
|
@@ -0,0 +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;;;OAGG;IACH,KAAK,CAAC,SAAS,CAAC,KAAa,EAAkC;QAC9D,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAA0B,CAAC;IAAA,CAC3G;IAED;;OAEG;IACH,KAAK,CAAC,YAAY,CAAC,KAAa,EAAgC;QAC/D,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,yBAAyB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAwB,CAAC;IAAA,CAC5G;IAED;;;OAGG;IACH,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;;;;OAIG;IACH,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,oEAAoE;QACpE,gEAAgE;QAChE,MAAM,cAAc,GAAI,GAA+D,EAAE,cAAc,CAAC;QACxG,OAAO;YACN,cAAc,EAAE,cAAwC;YACxD,GAAG;SACH,CAAC;IAAA,CACF;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 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"]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-kind verifier registry for the Outcome Adjudicator (Part 2 section 4).
|
|
3
|
+
*
|
|
4
|
+
* A flat, explicit registry keyed by unit-of-work `kind` string. No dynamic plugin
|
|
5
|
+
* discovery, no auto-loading - deliberately kept small and auditable per Part 2 section 4.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* The five-state verdict model for a single `run_id` (Part 2 section 2.4). This is the
|
|
9
|
+
* canonical, ground-truth output of the adjudication layer (Part 2 section 0).
|
|
10
|
+
*/
|
|
11
|
+
export type VerdictState = "CONFIRMED" | "CONTRADICTED" | "CORROBORATED-FAILURE" | "INDETERMINATE" | "VERIFIER-ERROR";
|
|
12
|
+
/**
|
|
13
|
+
* The closed, machine-readable vocabulary of adjudication reasons. Every
|
|
14
|
+
* `PerRunVerdict`/`AdjudicationResult` carries exactly one of these codes alongside its
|
|
15
|
+
* free-text `reason`; disposition logic (Part 3 §1, `loop.ts`) branches on the code only,
|
|
16
|
+
* never on the reason text, which exists purely for humans and logs.
|
|
17
|
+
*
|
|
18
|
+
* Ordered by severity, worst first: {@link reduceReasonCodes} resolves a set of codes to
|
|
19
|
+
* the earliest entry in this array, so escalation-class codes always win over
|
|
20
|
+
* reroute-class codes, which win over plain-retry codes.
|
|
21
|
+
*/
|
|
22
|
+
export declare const ADJUDICATION_REASON_CODES: readonly ["SCOPE_VIOLATION", "SCHEMA_DRIFT", "CONTENT_CHECK_FAILED", "NO_EVIDENCE_ON_SUCCESS", "EMPTY_ARTIFACT_CONTENT", "TRACE_CHECK_FAILED", "TRACE_ERROR_SPAN", "MIN_ACTIONS_UNMET", "RUN_STATUS_UNPARSEABLE", "RUN_FETCH_FAILED", "MALFORMED_REQUEST", "RUN_NOT_TERMINAL", "EVIDENCE_EMPTY", "FAILURE_REPORTED", "ALL_CHECKS_PASSED"];
|
|
23
|
+
export type AdjudicationReasonCode = (typeof ADJUDICATION_REASON_CODES)[number];
|
|
24
|
+
/**
|
|
25
|
+
* Worst-wins reduction over reason codes, using {@link ADJUDICATION_REASON_CODES} order
|
|
26
|
+
* (earlier = more severe). Used both for a single run's collected problems and for the
|
|
27
|
+
* record-level aggregation across `per_run` verdicts. Returns `ALL_CHECKS_PASSED` (the
|
|
28
|
+
* neutral, least-severe element) for an empty input; callers only invoke it with at least
|
|
29
|
+
* one code in practice.
|
|
30
|
+
*/
|
|
31
|
+
export declare function reduceReasonCodes(codes: readonly AdjudicationReasonCode[]): AdjudicationReasonCode;
|
|
32
|
+
/**
|
|
33
|
+
* Result of a single structural/content/trace check (Part 2 section 2.3).
|
|
34
|
+
*/
|
|
35
|
+
export interface CheckResult {
|
|
36
|
+
ok: boolean;
|
|
37
|
+
reason?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Optional machine-readable classification for a failed check. `SCOPE_VIOLATION` and
|
|
40
|
+
* `SCHEMA_DRIFT` are the codes the disposition layer treats specially (escalate /
|
|
41
|
+
* reroute-on-recurrence respectively); when absent, a failed check defaults to
|
|
42
|
+
* `CONTENT_CHECK_FAILED` (content checks) or `TRACE_CHECK_FAILED` (trace checks).
|
|
43
|
+
* Ignored when `ok` is true.
|
|
44
|
+
*/
|
|
45
|
+
code?: AdjudicationReasonCode;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A single per-kind verifier registry entry (Part 2 section 4). Every field beyond `kind`
|
|
49
|
+
* is optional; absence means the corresponding check/behavior is skipped or defaulted, as
|
|
50
|
+
* described in section 4.
|
|
51
|
+
*/
|
|
52
|
+
export interface VerifierRegistryEntry {
|
|
53
|
+
kind: string;
|
|
54
|
+
/** Default false. When true, an empty artifact list is not penalized (section 3). */
|
|
55
|
+
allow_zero_artifacts?: boolean;
|
|
56
|
+
/** e.g. ["markdown", "diff"] (section 4). */
|
|
57
|
+
expected_artifact_kinds?: string[];
|
|
58
|
+
/** Minimum matching trace spans required. Default 0 (no requirement, section 2.3/4). */
|
|
59
|
+
expected_min_actions?: number;
|
|
60
|
+
/** Default false. When true, retries above 1 are flagged (section 2.3). */
|
|
61
|
+
no_retry_masking?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Default false. When true, a `SUCCESS_REPORTED` run with both artifacts and traces
|
|
64
|
+
* empty is upgraded from INDETERMINATE to CONTRADICTED (section 3).
|
|
65
|
+
*/
|
|
66
|
+
no_evidence_on_success_is_contradiction?: boolean;
|
|
67
|
+
/** Format/schema check driven by the unit-of-work's content check hook (section 2.3). */
|
|
68
|
+
content_check?: (artifact: unknown) => CheckResult;
|
|
69
|
+
/** Trace-driven check hook (section 2.3). */
|
|
70
|
+
trace_check?: (traces: unknown) => CheckResult;
|
|
71
|
+
/**
|
|
72
|
+
* Optional corrective payload builder, invoked only when the record-level verdict is
|
|
73
|
+
* not CONFIRMED (section 4). Absent means no augmented payload is produced for this
|
|
74
|
+
* kind - callers resubmit the unmodified original payload.
|
|
75
|
+
*/
|
|
76
|
+
build_augmented_payload?: (verdict: VerdictState, artifacts: unknown, traces: unknown) => unknown;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The conservative, structural-only fallback verifier used for any `kind` without a
|
|
80
|
+
* registered entry (Part 2 section 4). It can never reach CONFIRMED through a laxer path
|
|
81
|
+
* than a registered kind would, and intentionally defines no `content_check`,
|
|
82
|
+
* `trace_check`, or `build_augmented_payload`.
|
|
83
|
+
*/
|
|
84
|
+
export declare const DEFAULT_VERIFIER: VerifierRegistryEntry;
|
|
85
|
+
/**
|
|
86
|
+
* Builds a flat, Map-backed lookup table for verifier registry entries (Part 2 section 4).
|
|
87
|
+
* No dynamic plugin discovery - the caller supplies the full, explicit entry list up front.
|
|
88
|
+
* Lookups for a `kind` with no registered entry fall back to {@link DEFAULT_VERIFIER}.
|
|
89
|
+
*/
|
|
90
|
+
export declare function createVerifierRegistry(entries: VerifierRegistryEntry[]): {
|
|
91
|
+
get(kind: string): VerifierRegistryEntry;
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=adjudicator-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adjudicator-registry.d.ts","sourceRoot":"","sources":["../src/adjudicator-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,cAAc,GAAG,sBAAsB,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAEtH;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,2UA+B5B,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,sBAAsB,EAAE,GAAG,sBAAsB,CAKlG;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,sBAAsB,CAAC;CAC9B;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,qFAAqF;IACrF,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,6CAA6C;IAC7C,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;IACnC,wFAAwF;IACxF,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,2EAA2E;IAC3E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,uCAAuC,CAAC,EAAE,OAAO,CAAC;IAClD,yFAAyF;IACzF,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,WAAW,CAAC;IACnD,6CAA6C;IAC7C,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,WAAW,CAAC;IAC/C;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC;CAClG;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,qBAG9B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,qBAAqB,EAAE,GAAG;IAAE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAAA;CAAE,CAUrH","sourcesContent":["/**\n * Per-kind verifier registry for the Outcome Adjudicator (Part 2 section 4).\n *\n * A flat, explicit registry keyed by unit-of-work `kind` string. No dynamic plugin\n * discovery, no auto-loading - deliberately kept small and auditable per Part 2 section 4.\n */\n\n/**\n * The five-state verdict model for a single `run_id` (Part 2 section 2.4). This is the\n * canonical, ground-truth output of the adjudication layer (Part 2 section 0).\n */\nexport type VerdictState = \"CONFIRMED\" | \"CONTRADICTED\" | \"CORROBORATED-FAILURE\" | \"INDETERMINATE\" | \"VERIFIER-ERROR\";\n\n/**\n * The closed, machine-readable vocabulary of adjudication reasons. Every\n * `PerRunVerdict`/`AdjudicationResult` carries exactly one of these codes alongside its\n * free-text `reason`; disposition logic (Part 3 §1, `loop.ts`) branches on the code only,\n * never on the reason text, which exists purely for humans and logs.\n *\n * Ordered by severity, worst first: {@link reduceReasonCodes} resolves a set of codes to\n * the earliest entry in this array, so escalation-class codes always win over\n * reroute-class codes, which win over plain-retry codes.\n */\nexport const ADJUDICATION_REASON_CODES = [\n\t/** A safety boundary was crossed (e.g. writes outside the lane's scope). Never auto-retried. */\n\t\"SCOPE_VIOLATION\",\n\t/** Output shape/schema does not match the packet's contract (explicit hook classification). */\n\t\"SCHEMA_DRIFT\",\n\t/** A registered `content_check` hook rejected an artifact (default code for failed content checks). */\n\t\"CONTENT_CHECK_FAILED\",\n\t/** Reported success but artifacts and traces are both empty, for a kind where that is contradictory. */\n\t\"NO_EVIDENCE_ON_SUCCESS\",\n\t/** An artifact exists but is empty or whitespace-only. */\n\t\"EMPTY_ARTIFACT_CONTENT\",\n\t/** A registered `trace_check` hook rejected the trace set (default code for failed trace checks). */\n\t\"TRACE_CHECK_FAILED\",\n\t/** The error-span scan found ERROR-severity spans under a reported success. */\n\t\"TRACE_ERROR_SPAN\",\n\t/** Fewer action spans than the registry entry's `expected_min_actions`. */\n\t\"MIN_ACTIONS_UNMET\",\n\t/** `getRun` payload carried no recognizable status field (checker failure, not task failure). */\n\t\"RUN_STATUS_UNPARSEABLE\",\n\t/** The evidence fetch/check sequence itself threw for this run. */\n\t\"RUN_FETCH_FAILED\",\n\t/** The `AdjudicationRequest` itself was malformed (missing kind / empty run_ids). */\n\t\"MALFORMED_REQUEST\",\n\t/** The run has not reached a terminal status yet. */\n\t\"RUN_NOT_TERMINAL\",\n\t/** Artifacts and/or traces were unexpectedly empty — too thin to judge either way. */\n\t\"EVIDENCE_EMPTY\",\n\t/** The run reported failure and the evidence does not contradict that report. */\n\t\"FAILURE_REPORTED\",\n\t/** Every check passed. */\n\t\"ALL_CHECKS_PASSED\",\n] as const;\n\nexport type AdjudicationReasonCode = (typeof ADJUDICATION_REASON_CODES)[number];\n\n/**\n * Worst-wins reduction over reason codes, using {@link ADJUDICATION_REASON_CODES} order\n * (earlier = more severe). Used both for a single run's collected problems and for the\n * record-level aggregation across `per_run` verdicts. Returns `ALL_CHECKS_PASSED` (the\n * neutral, least-severe element) for an empty input; callers only invoke it with at least\n * one code in practice.\n */\nexport function reduceReasonCodes(codes: readonly AdjudicationReasonCode[]): AdjudicationReasonCode {\n\tfor (const code of ADJUDICATION_REASON_CODES) {\n\t\tif (codes.includes(code)) return code;\n\t}\n\treturn \"ALL_CHECKS_PASSED\";\n}\n\n/**\n * Result of a single structural/content/trace check (Part 2 section 2.3).\n */\nexport interface CheckResult {\n\tok: boolean;\n\treason?: string;\n\t/**\n\t * Optional machine-readable classification for a failed check. `SCOPE_VIOLATION` and\n\t * `SCHEMA_DRIFT` are the codes the disposition layer treats specially (escalate /\n\t * reroute-on-recurrence respectively); when absent, a failed check defaults to\n\t * `CONTENT_CHECK_FAILED` (content checks) or `TRACE_CHECK_FAILED` (trace checks).\n\t * Ignored when `ok` is true.\n\t */\n\tcode?: AdjudicationReasonCode;\n}\n\n/**\n * A single per-kind verifier registry entry (Part 2 section 4). Every field beyond `kind`\n * is optional; absence means the corresponding check/behavior is skipped or defaulted, as\n * described in section 4.\n */\nexport interface VerifierRegistryEntry {\n\tkind: string;\n\t/** Default false. When true, an empty artifact list is not penalized (section 3). */\n\tallow_zero_artifacts?: boolean;\n\t/** e.g. [\"markdown\", \"diff\"] (section 4). */\n\texpected_artifact_kinds?: string[];\n\t/** Minimum matching trace spans required. Default 0 (no requirement, section 2.3/4). */\n\texpected_min_actions?: number;\n\t/** Default false. When true, retries above 1 are flagged (section 2.3). */\n\tno_retry_masking?: boolean;\n\t/**\n\t * Default false. When true, a `SUCCESS_REPORTED` run with both artifacts and traces\n\t * empty is upgraded from INDETERMINATE to CONTRADICTED (section 3).\n\t */\n\tno_evidence_on_success_is_contradiction?: boolean;\n\t/** Format/schema check driven by the unit-of-work's content check hook (section 2.3). */\n\tcontent_check?: (artifact: unknown) => CheckResult;\n\t/** Trace-driven check hook (section 2.3). */\n\ttrace_check?: (traces: unknown) => CheckResult;\n\t/**\n\t * Optional corrective payload builder, invoked only when the record-level verdict is\n\t * not CONFIRMED (section 4). Absent means no augmented payload is produced for this\n\t * kind - callers resubmit the unmodified original payload.\n\t */\n\tbuild_augmented_payload?: (verdict: VerdictState, artifacts: unknown, traces: unknown) => unknown;\n}\n\n/**\n * The conservative, structural-only fallback verifier used for any `kind` without a\n * registered entry (Part 2 section 4). It can never reach CONFIRMED through a laxer path\n * than a registered kind would, and intentionally defines no `content_check`,\n * `trace_check`, or `build_augmented_payload`.\n */\nexport const DEFAULT_VERIFIER: VerifierRegistryEntry = {\n\tkind: \"DEFAULT\",\n\tallow_zero_artifacts: false,\n};\n\n/**\n * Builds a flat, Map-backed lookup table for verifier registry entries (Part 2 section 4).\n * No dynamic plugin discovery - the caller supplies the full, explicit entry list up front.\n * Lookups for a `kind` with no registered entry fall back to {@link DEFAULT_VERIFIER}.\n */\nexport function createVerifierRegistry(entries: VerifierRegistryEntry[]): { get(kind: string): VerifierRegistryEntry } {\n\tconst byKind = new Map<string, VerifierRegistryEntry>();\n\tfor (const entry of entries) {\n\t\tbyKind.set(entry.kind, entry);\n\t}\n\treturn {\n\t\tget(kind: string): VerifierRegistryEntry {\n\t\t\treturn byKind.get(kind) ?? DEFAULT_VERIFIER;\n\t\t},\n\t};\n}\n"]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-kind verifier registry for the Outcome Adjudicator (Part 2 section 4).
|
|
3
|
+
*
|
|
4
|
+
* A flat, explicit registry keyed by unit-of-work `kind` string. No dynamic plugin
|
|
5
|
+
* discovery, no auto-loading - deliberately kept small and auditable per Part 2 section 4.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* The closed, machine-readable vocabulary of adjudication reasons. Every
|
|
9
|
+
* `PerRunVerdict`/`AdjudicationResult` carries exactly one of these codes alongside its
|
|
10
|
+
* free-text `reason`; disposition logic (Part 3 §1, `loop.ts`) branches on the code only,
|
|
11
|
+
* never on the reason text, which exists purely for humans and logs.
|
|
12
|
+
*
|
|
13
|
+
* Ordered by severity, worst first: {@link reduceReasonCodes} resolves a set of codes to
|
|
14
|
+
* the earliest entry in this array, so escalation-class codes always win over
|
|
15
|
+
* reroute-class codes, which win over plain-retry codes.
|
|
16
|
+
*/
|
|
17
|
+
export const ADJUDICATION_REASON_CODES = [
|
|
18
|
+
/** A safety boundary was crossed (e.g. writes outside the lane's scope). Never auto-retried. */
|
|
19
|
+
"SCOPE_VIOLATION",
|
|
20
|
+
/** Output shape/schema does not match the packet's contract (explicit hook classification). */
|
|
21
|
+
"SCHEMA_DRIFT",
|
|
22
|
+
/** A registered `content_check` hook rejected an artifact (default code for failed content checks). */
|
|
23
|
+
"CONTENT_CHECK_FAILED",
|
|
24
|
+
/** Reported success but artifacts and traces are both empty, for a kind where that is contradictory. */
|
|
25
|
+
"NO_EVIDENCE_ON_SUCCESS",
|
|
26
|
+
/** An artifact exists but is empty or whitespace-only. */
|
|
27
|
+
"EMPTY_ARTIFACT_CONTENT",
|
|
28
|
+
/** A registered `trace_check` hook rejected the trace set (default code for failed trace checks). */
|
|
29
|
+
"TRACE_CHECK_FAILED",
|
|
30
|
+
/** The error-span scan found ERROR-severity spans under a reported success. */
|
|
31
|
+
"TRACE_ERROR_SPAN",
|
|
32
|
+
/** Fewer action spans than the registry entry's `expected_min_actions`. */
|
|
33
|
+
"MIN_ACTIONS_UNMET",
|
|
34
|
+
/** `getRun` payload carried no recognizable status field (checker failure, not task failure). */
|
|
35
|
+
"RUN_STATUS_UNPARSEABLE",
|
|
36
|
+
/** The evidence fetch/check sequence itself threw for this run. */
|
|
37
|
+
"RUN_FETCH_FAILED",
|
|
38
|
+
/** The `AdjudicationRequest` itself was malformed (missing kind / empty run_ids). */
|
|
39
|
+
"MALFORMED_REQUEST",
|
|
40
|
+
/** The run has not reached a terminal status yet. */
|
|
41
|
+
"RUN_NOT_TERMINAL",
|
|
42
|
+
/** Artifacts and/or traces were unexpectedly empty — too thin to judge either way. */
|
|
43
|
+
"EVIDENCE_EMPTY",
|
|
44
|
+
/** The run reported failure and the evidence does not contradict that report. */
|
|
45
|
+
"FAILURE_REPORTED",
|
|
46
|
+
/** Every check passed. */
|
|
47
|
+
"ALL_CHECKS_PASSED",
|
|
48
|
+
];
|
|
49
|
+
/**
|
|
50
|
+
* Worst-wins reduction over reason codes, using {@link ADJUDICATION_REASON_CODES} order
|
|
51
|
+
* (earlier = more severe). Used both for a single run's collected problems and for the
|
|
52
|
+
* record-level aggregation across `per_run` verdicts. Returns `ALL_CHECKS_PASSED` (the
|
|
53
|
+
* neutral, least-severe element) for an empty input; callers only invoke it with at least
|
|
54
|
+
* one code in practice.
|
|
55
|
+
*/
|
|
56
|
+
export function reduceReasonCodes(codes) {
|
|
57
|
+
for (const code of ADJUDICATION_REASON_CODES) {
|
|
58
|
+
if (codes.includes(code))
|
|
59
|
+
return code;
|
|
60
|
+
}
|
|
61
|
+
return "ALL_CHECKS_PASSED";
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The conservative, structural-only fallback verifier used for any `kind` without a
|
|
65
|
+
* registered entry (Part 2 section 4). It can never reach CONFIRMED through a laxer path
|
|
66
|
+
* than a registered kind would, and intentionally defines no `content_check`,
|
|
67
|
+
* `trace_check`, or `build_augmented_payload`.
|
|
68
|
+
*/
|
|
69
|
+
export const DEFAULT_VERIFIER = {
|
|
70
|
+
kind: "DEFAULT",
|
|
71
|
+
allow_zero_artifacts: false,
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Builds a flat, Map-backed lookup table for verifier registry entries (Part 2 section 4).
|
|
75
|
+
* No dynamic plugin discovery - the caller supplies the full, explicit entry list up front.
|
|
76
|
+
* Lookups for a `kind` with no registered entry fall back to {@link DEFAULT_VERIFIER}.
|
|
77
|
+
*/
|
|
78
|
+
export function createVerifierRegistry(entries) {
|
|
79
|
+
const byKind = new Map();
|
|
80
|
+
for (const entry of entries) {
|
|
81
|
+
byKind.set(entry.kind, entry);
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
get(kind) {
|
|
85
|
+
return byKind.get(kind) ?? DEFAULT_VERIFIER;
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=adjudicator-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adjudicator-registry.js","sourceRoot":"","sources":["../src/adjudicator-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACxC,gGAAgG;IAChG,iBAAiB;IACjB,+FAA+F;IAC/F,cAAc;IACd,uGAAuG;IACvG,sBAAsB;IACtB,wGAAwG;IACxG,wBAAwB;IACxB,0DAA0D;IAC1D,wBAAwB;IACxB,qGAAqG;IACrG,oBAAoB;IACpB,+EAA+E;IAC/E,kBAAkB;IAClB,2EAA2E;IAC3E,mBAAmB;IACnB,iGAAiG;IACjG,wBAAwB;IACxB,mEAAmE;IACnE,kBAAkB;IAClB,qFAAqF;IACrF,mBAAmB;IACnB,qDAAqD;IACrD,kBAAkB;IAClB,wFAAsF;IACtF,gBAAgB;IAChB,iFAAiF;IACjF,kBAAkB;IAClB,0BAA0B;IAC1B,mBAAmB;CACV,CAAC;AAIX;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAwC,EAA0B;IACnG,KAAK,MAAM,IAAI,IAAI,yBAAyB,EAAE,CAAC;QAC9C,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;IACvC,CAAC;IACD,OAAO,mBAAmB,CAAC;AAAA,CAC3B;AAkDD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA0B;IACtD,IAAI,EAAE,SAAS;IACf,oBAAoB,EAAE,KAAK;CAC3B,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAgC,EAAgD;IACtH,MAAM,MAAM,GAAG,IAAI,GAAG,EAAiC,CAAC;IACxD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO;QACN,GAAG,CAAC,IAAY,EAAyB;YACxC,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,gBAAgB,CAAC;QAAA,CAC5C;KACD,CAAC;AAAA,CACF","sourcesContent":["/**\n * Per-kind verifier registry for the Outcome Adjudicator (Part 2 section 4).\n *\n * A flat, explicit registry keyed by unit-of-work `kind` string. No dynamic plugin\n * discovery, no auto-loading - deliberately kept small and auditable per Part 2 section 4.\n */\n\n/**\n * The five-state verdict model for a single `run_id` (Part 2 section 2.4). This is the\n * canonical, ground-truth output of the adjudication layer (Part 2 section 0).\n */\nexport type VerdictState = \"CONFIRMED\" | \"CONTRADICTED\" | \"CORROBORATED-FAILURE\" | \"INDETERMINATE\" | \"VERIFIER-ERROR\";\n\n/**\n * The closed, machine-readable vocabulary of adjudication reasons. Every\n * `PerRunVerdict`/`AdjudicationResult` carries exactly one of these codes alongside its\n * free-text `reason`; disposition logic (Part 3 §1, `loop.ts`) branches on the code only,\n * never on the reason text, which exists purely for humans and logs.\n *\n * Ordered by severity, worst first: {@link reduceReasonCodes} resolves a set of codes to\n * the earliest entry in this array, so escalation-class codes always win over\n * reroute-class codes, which win over plain-retry codes.\n */\nexport const ADJUDICATION_REASON_CODES = [\n\t/** A safety boundary was crossed (e.g. writes outside the lane's scope). Never auto-retried. */\n\t\"SCOPE_VIOLATION\",\n\t/** Output shape/schema does not match the packet's contract (explicit hook classification). */\n\t\"SCHEMA_DRIFT\",\n\t/** A registered `content_check` hook rejected an artifact (default code for failed content checks). */\n\t\"CONTENT_CHECK_FAILED\",\n\t/** Reported success but artifacts and traces are both empty, for a kind where that is contradictory. */\n\t\"NO_EVIDENCE_ON_SUCCESS\",\n\t/** An artifact exists but is empty or whitespace-only. */\n\t\"EMPTY_ARTIFACT_CONTENT\",\n\t/** A registered `trace_check` hook rejected the trace set (default code for failed trace checks). */\n\t\"TRACE_CHECK_FAILED\",\n\t/** The error-span scan found ERROR-severity spans under a reported success. */\n\t\"TRACE_ERROR_SPAN\",\n\t/** Fewer action spans than the registry entry's `expected_min_actions`. */\n\t\"MIN_ACTIONS_UNMET\",\n\t/** `getRun` payload carried no recognizable status field (checker failure, not task failure). */\n\t\"RUN_STATUS_UNPARSEABLE\",\n\t/** The evidence fetch/check sequence itself threw for this run. */\n\t\"RUN_FETCH_FAILED\",\n\t/** The `AdjudicationRequest` itself was malformed (missing kind / empty run_ids). */\n\t\"MALFORMED_REQUEST\",\n\t/** The run has not reached a terminal status yet. */\n\t\"RUN_NOT_TERMINAL\",\n\t/** Artifacts and/or traces were unexpectedly empty — too thin to judge either way. */\n\t\"EVIDENCE_EMPTY\",\n\t/** The run reported failure and the evidence does not contradict that report. */\n\t\"FAILURE_REPORTED\",\n\t/** Every check passed. */\n\t\"ALL_CHECKS_PASSED\",\n] as const;\n\nexport type AdjudicationReasonCode = (typeof ADJUDICATION_REASON_CODES)[number];\n\n/**\n * Worst-wins reduction over reason codes, using {@link ADJUDICATION_REASON_CODES} order\n * (earlier = more severe). Used both for a single run's collected problems and for the\n * record-level aggregation across `per_run` verdicts. Returns `ALL_CHECKS_PASSED` (the\n * neutral, least-severe element) for an empty input; callers only invoke it with at least\n * one code in practice.\n */\nexport function reduceReasonCodes(codes: readonly AdjudicationReasonCode[]): AdjudicationReasonCode {\n\tfor (const code of ADJUDICATION_REASON_CODES) {\n\t\tif (codes.includes(code)) return code;\n\t}\n\treturn \"ALL_CHECKS_PASSED\";\n}\n\n/**\n * Result of a single structural/content/trace check (Part 2 section 2.3).\n */\nexport interface CheckResult {\n\tok: boolean;\n\treason?: string;\n\t/**\n\t * Optional machine-readable classification for a failed check. `SCOPE_VIOLATION` and\n\t * `SCHEMA_DRIFT` are the codes the disposition layer treats specially (escalate /\n\t * reroute-on-recurrence respectively); when absent, a failed check defaults to\n\t * `CONTENT_CHECK_FAILED` (content checks) or `TRACE_CHECK_FAILED` (trace checks).\n\t * Ignored when `ok` is true.\n\t */\n\tcode?: AdjudicationReasonCode;\n}\n\n/**\n * A single per-kind verifier registry entry (Part 2 section 4). Every field beyond `kind`\n * is optional; absence means the corresponding check/behavior is skipped or defaulted, as\n * described in section 4.\n */\nexport interface VerifierRegistryEntry {\n\tkind: string;\n\t/** Default false. When true, an empty artifact list is not penalized (section 3). */\n\tallow_zero_artifacts?: boolean;\n\t/** e.g. [\"markdown\", \"diff\"] (section 4). */\n\texpected_artifact_kinds?: string[];\n\t/** Minimum matching trace spans required. Default 0 (no requirement, section 2.3/4). */\n\texpected_min_actions?: number;\n\t/** Default false. When true, retries above 1 are flagged (section 2.3). */\n\tno_retry_masking?: boolean;\n\t/**\n\t * Default false. When true, a `SUCCESS_REPORTED` run with both artifacts and traces\n\t * empty is upgraded from INDETERMINATE to CONTRADICTED (section 3).\n\t */\n\tno_evidence_on_success_is_contradiction?: boolean;\n\t/** Format/schema check driven by the unit-of-work's content check hook (section 2.3). */\n\tcontent_check?: (artifact: unknown) => CheckResult;\n\t/** Trace-driven check hook (section 2.3). */\n\ttrace_check?: (traces: unknown) => CheckResult;\n\t/**\n\t * Optional corrective payload builder, invoked only when the record-level verdict is\n\t * not CONFIRMED (section 4). Absent means no augmented payload is produced for this\n\t * kind - callers resubmit the unmodified original payload.\n\t */\n\tbuild_augmented_payload?: (verdict: VerdictState, artifacts: unknown, traces: unknown) => unknown;\n}\n\n/**\n * The conservative, structural-only fallback verifier used for any `kind` without a\n * registered entry (Part 2 section 4). It can never reach CONFIRMED through a laxer path\n * than a registered kind would, and intentionally defines no `content_check`,\n * `trace_check`, or `build_augmented_payload`.\n */\nexport const DEFAULT_VERIFIER: VerifierRegistryEntry = {\n\tkind: \"DEFAULT\",\n\tallow_zero_artifacts: false,\n};\n\n/**\n * Builds a flat, Map-backed lookup table for verifier registry entries (Part 2 section 4).\n * No dynamic plugin discovery - the caller supplies the full, explicit entry list up front.\n * Lookups for a `kind` with no registered entry fall back to {@link DEFAULT_VERIFIER}.\n */\nexport function createVerifierRegistry(entries: VerifierRegistryEntry[]): { get(kind: string): VerifierRegistryEntry } {\n\tconst byKind = new Map<string, VerifierRegistryEntry>();\n\tfor (const entry of entries) {\n\t\tbyKind.set(entry.kind, entry);\n\t}\n\treturn {\n\t\tget(kind: string): VerifierRegistryEntry {\n\t\t\treturn byKind.get(kind) ?? DEFAULT_VERIFIER;\n\t\t},\n\t};\n}\n"]}
|