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.
Files changed (90) hide show
  1. package/README.md +49 -0
  2. package/dist/adaptorch-client.d.ts +184 -0
  3. package/dist/adaptorch-client.d.ts.map +1 -0
  4. package/dist/adaptorch-client.js +109 -0
  5. package/dist/adaptorch-client.js.map +1 -0
  6. package/dist/adjudicator-registry.d.ts +93 -0
  7. package/dist/adjudicator-registry.d.ts.map +1 -0
  8. package/dist/adjudicator-registry.js +89 -0
  9. package/dist/adjudicator-registry.js.map +1 -0
  10. package/dist/adjudicator.d.ts +73 -0
  11. package/dist/adjudicator.d.ts.map +1 -0
  12. package/dist/adjudicator.js +356 -0
  13. package/dist/adjudicator.js.map +1 -0
  14. package/dist/b2c-mapper.d.ts +25 -0
  15. package/dist/b2c-mapper.d.ts.map +1 -0
  16. package/dist/b2c-mapper.js +186 -0
  17. package/dist/b2c-mapper.js.map +1 -0
  18. package/dist/b2c-verdict.d.ts +66 -0
  19. package/dist/b2c-verdict.d.ts.map +1 -0
  20. package/dist/b2c-verdict.js +5 -0
  21. package/dist/b2c-verdict.js.map +1 -0
  22. package/dist/deep-wall.d.ts +80 -0
  23. package/dist/deep-wall.d.ts.map +1 -0
  24. package/dist/deep-wall.js +97 -0
  25. package/dist/deep-wall.js.map +1 -0
  26. package/dist/evaluate-correctness-wall.d.ts +35 -0
  27. package/dist/evaluate-correctness-wall.d.ts.map +1 -0
  28. package/dist/evaluate-correctness-wall.js +128 -0
  29. package/dist/evaluate-correctness-wall.js.map +1 -0
  30. package/dist/in-memory-adaptorch.d.ts +12 -0
  31. package/dist/in-memory-adaptorch.d.ts.map +1 -0
  32. package/dist/in-memory-adaptorch.js +26 -0
  33. package/dist/in-memory-adaptorch.js.map +1 -0
  34. package/dist/index.d.ts +46 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +28 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/live-adaptorch-transport.d.ts +14 -0
  39. package/dist/live-adaptorch-transport.d.ts.map +1 -0
  40. package/dist/live-adaptorch-transport.js +19 -0
  41. package/dist/live-adaptorch-transport.js.map +1 -0
  42. package/dist/loop.d.ts +149 -0
  43. package/dist/loop.d.ts.map +1 -0
  44. package/dist/loop.js +219 -0
  45. package/dist/loop.js.map +1 -0
  46. package/dist/mcp-introspection-transport.d.ts +18 -0
  47. package/dist/mcp-introspection-transport.d.ts.map +1 -0
  48. package/dist/mcp-introspection-transport.js +29 -0
  49. package/dist/mcp-introspection-transport.js.map +1 -0
  50. package/dist/policy-wall.d.ts +34 -0
  51. package/dist/policy-wall.d.ts.map +1 -0
  52. package/dist/policy-wall.js +125 -0
  53. package/dist/policy-wall.js.map +1 -0
  54. package/dist/receipt-signature.d.ts +28 -0
  55. package/dist/receipt-signature.d.ts.map +1 -0
  56. package/dist/receipt-signature.js +30 -0
  57. package/dist/receipt-signature.js.map +1 -0
  58. package/dist/regenerate-packet.d.ts +25 -0
  59. package/dist/regenerate-packet.d.ts.map +1 -0
  60. package/dist/regenerate-packet.js +29 -0
  61. package/dist/regenerate-packet.js.map +1 -0
  62. package/dist/repair-budget.d.ts +24 -0
  63. package/dist/repair-budget.d.ts.map +1 -0
  64. package/dist/repair-budget.js +44 -0
  65. package/dist/repair-budget.js.map +1 -0
  66. package/dist/repair-loop.d.ts +18 -0
  67. package/dist/repair-loop.d.ts.map +1 -0
  68. package/dist/repair-loop.js +54 -0
  69. package/dist/repair-loop.js.map +1 -0
  70. package/dist/retry-backoff.d.ts +56 -0
  71. package/dist/retry-backoff.d.ts.map +1 -0
  72. package/dist/retry-backoff.js +75 -0
  73. package/dist/retry-backoff.js.map +1 -0
  74. package/dist/signed-receipt.d.ts +29 -0
  75. package/dist/signed-receipt.d.ts.map +1 -0
  76. package/dist/signed-receipt.js +25 -0
  77. package/dist/signed-receipt.js.map +1 -0
  78. package/dist/state-machine.d.ts +40 -0
  79. package/dist/state-machine.d.ts.map +1 -0
  80. package/dist/state-machine.js +88 -0
  81. package/dist/state-machine.js.map +1 -0
  82. package/dist/types.d.ts +149 -0
  83. package/dist/types.d.ts.map +1 -0
  84. package/dist/types.js +16 -0
  85. package/dist/types.js.map +1 -0
  86. package/dist/wall-meta.d.ts +3 -0
  87. package/dist/wall-meta.d.ts.map +1 -0
  88. package/dist/wall-meta.js +3 -0
  89. package/dist/wall-meta.js.map +1 -0
  90. package/package.json +46 -0
@@ -0,0 +1,128 @@
1
+ /**
2
+ * B2C Correctness Wall orchestration — fast wall + optional OA adjudication.
3
+ */
4
+ import { adjudicate } from "./adjudicator.js";
5
+ import { createVerifierRegistry } from "./adjudicator-registry.js";
6
+ import { mapToB2C } from "./b2c-mapper.js";
7
+ import { DEEP_RUNNER_NOT_WIRED, DEEP_WALL_UNAVAILABLE, isDeepRunnerCompletionAllowed, resolveDeepWallPhaseFromEnv, runDeepWall, } from "./deep-wall.js";
8
+ import { runFastWall } from "./policy-wall.js";
9
+ import { signWallReceipt } from "./receipt-signature.js";
10
+ import { deriveRepairHints } from "./repair-loop.js";
11
+ import { buildVerificationDigest } from "./signed-receipt.js";
12
+ import { CORRECTNESS_WALL_VERSION } from "./wall-meta.js";
13
+ export async function evaluateCorrectnessWall(params) {
14
+ const runIds = params.runIds ?? [];
15
+ const previewOnly = params.previewOnly === true;
16
+ const registry = params.registry ?? createVerifierRegistry([]);
17
+ const wall = runFastWall({
18
+ diffText: params.diffText,
19
+ approvedWriteScope: params.approvedWriteScope,
20
+ runIds,
21
+ previewOnly,
22
+ });
23
+ let adjudication;
24
+ const useOa = runIds.length > 0 && !previewOnly && params.client !== undefined;
25
+ if (useOa && params.client !== undefined) {
26
+ const request = {
27
+ dispatch_record_id: params.dispatchRecordId ?? "b2c-wall",
28
+ kind: params.kind,
29
+ run_ids: runIds,
30
+ };
31
+ adjudication = await adjudicate(request, params.client, registry);
32
+ }
33
+ let policyFlags = wall.flags;
34
+ if (adjudication !== undefined) {
35
+ policyFlags = wall.flags.filter((f) => f !== "EVIDENCE_DAG_INCOMPLETE");
36
+ }
37
+ const provisional = mapToB2C({
38
+ kind: params.kind,
39
+ packetId: params.packetId,
40
+ dispatchRecordId: params.dispatchRecordId,
41
+ runIds,
42
+ previewOnly,
43
+ policyFlags,
44
+ diffPaths: wall.diffPaths,
45
+ adjudication,
46
+ });
47
+ const repairHints = deriveRepairHints({
48
+ userVerdict: provisional.verdictCard.verdict,
49
+ policyFlags,
50
+ adjudicationReasonCode: adjudication?.reason_code,
51
+ previewOnly,
52
+ diffPaths: wall.diffPaths,
53
+ });
54
+ const mapped = mapToB2C({
55
+ kind: params.kind,
56
+ packetId: params.packetId,
57
+ dispatchRecordId: params.dispatchRecordId,
58
+ runIds,
59
+ previewOnly,
60
+ policyFlags,
61
+ diffPaths: wall.diffPaths,
62
+ adjudication,
63
+ repairHints,
64
+ });
65
+ const verificationDigest = buildVerificationDigest({
66
+ patchText: params.diffText,
67
+ evidenceChunks: runIds.length > 0 ? runIds : undefined,
68
+ wallVersion: CORRECTNESS_WALL_VERSION,
69
+ });
70
+ let verdictCard = mapped.verdictCard;
71
+ let receipt = {
72
+ ...mapped.receipt,
73
+ verificationDigest,
74
+ wallVersion: CORRECTNESS_WALL_VERSION,
75
+ };
76
+ const signingSecret = params.receiptSigningSecret?.trim();
77
+ if (signingSecret !== undefined && signingSecret.length > 0 && verificationDigest !== undefined) {
78
+ receipt = {
79
+ ...receipt,
80
+ signedReceipt: signWallReceipt({
81
+ digest: verificationDigest,
82
+ wallVersion: CORRECTNESS_WALL_VERSION,
83
+ secret: signingSecret,
84
+ }),
85
+ };
86
+ }
87
+ if (params.deepWall === true) {
88
+ const deep = await runDeepWall({
89
+ kind: params.kind,
90
+ runIds,
91
+ packetId: params.packetId,
92
+ phase: resolveDeepWallPhaseFromEnv(),
93
+ runner: params.deepWallRunner,
94
+ allowCompletion: params.deepWallAllowCompletion,
95
+ });
96
+ const policyFlags = [...receipt.policyFlags];
97
+ if (deep.status !== "completed") {
98
+ if (!policyFlags.includes(DEEP_WALL_UNAVAILABLE)) {
99
+ policyFlags.push(DEEP_WALL_UNAVAILABLE);
100
+ }
101
+ if (!isDeepRunnerCompletionAllowed() && !policyFlags.includes(DEEP_RUNNER_NOT_WIRED)) {
102
+ policyFlags.push(DEEP_RUNNER_NOT_WIRED);
103
+ }
104
+ }
105
+ for (const f of deep.runnerFlags ?? []) {
106
+ if (!policyFlags.includes(f))
107
+ policyFlags.push(f);
108
+ }
109
+ const limitsCode = deep.limits?.[0] ?? verdictCard.limits.code;
110
+ verdictCard = {
111
+ ...verdictCard,
112
+ limits: {
113
+ ...verdictCard.limits,
114
+ requiresHumanReview: deep.status !== "completed",
115
+ code: limitsCode ?? verdictCard.limits.code,
116
+ },
117
+ blocked_reasons: [...new Set([...verdictCard.blocked_reasons, deep.message])],
118
+ };
119
+ receipt = {
120
+ ...receipt,
121
+ policyFlags,
122
+ deepWallStatus: deep.status,
123
+ deepWallEvidence: deep.evidence,
124
+ };
125
+ }
126
+ return { verdictCard, receipt };
127
+ }
128
+ //# sourceMappingURL=evaluate-correctness-wall.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate-correctness-wall.js","sourceRoot":"","sources":["../src/evaluate-correctness-wall.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAA4B,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAA8B,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EACN,qBAAqB,EACrB,qBAAqB,EAErB,6BAA6B,EAC7B,2BAA2B,EAC3B,WAAW,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC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AAG;YACb,GAAG,WAAW;YACd,MAAM,EAAE;gBACP,GAAG,WAAW,CAAC,MAAM;gBACrB,mBAAmB,EAAE,IAAI,CAAC,MAAM,KAAK,WAAW;gBAChD,IAAI,EAAE,UAAU,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI;aAC3C;YACD,eAAe,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,eAAe,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;SAC7E,CAAC;QACF,OAAO,GAAG;YACT,GAAG,OAAO;YACV,WAAW;YACX,cAAc,EAAE,IAAI,CAAC,MAAM;YAC3B,gBAAgB,EAAE,IAAI,CAAC,QAAQ;SAC/B,CAAC;IACH,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;AAAA,CAChC","sourcesContent":["/**\n * B2C Correctness Wall orchestration — fast wall + optional OA adjudication.\n */\n\nimport type { AdaptOrchClient } from \"./adaptorch-client.ts\";\nimport { type AdjudicationRequest, adjudicate } from \"./adjudicator.ts\";\nimport { createVerifierRegistry, type VerifierRegistryEntry } from \"./adjudicator-registry.ts\";\nimport { mapToB2C } from \"./b2c-mapper.ts\";\nimport type { VerdictCard, VerificationReceipt } from \"./b2c-verdict.ts\";\nimport {\n\tDEEP_RUNNER_NOT_WIRED,\n\tDEEP_WALL_UNAVAILABLE,\n\ttype DeepWallRunnerFn,\n\tisDeepRunnerCompletionAllowed,\n\tresolveDeepWallPhaseFromEnv,\n\trunDeepWall,\n} from \"./deep-wall.ts\";\nimport { runFastWall } from \"./policy-wall.ts\";\nimport { signWallReceipt } from \"./receipt-signature.ts\";\nimport { deriveRepairHints } from \"./repair-loop.ts\";\nimport { buildVerificationDigest } from \"./signed-receipt.ts\";\nimport { CORRECTNESS_WALL_VERSION } from \"./wall-meta.ts\";\n\nexport interface EvaluateCorrectnessWallParams {\n\tkind: string;\n\trunIds?: string[];\n\tdispatchRecordId?: string;\n\tapprovedWriteScope?: string[];\n\tpreviewOnly?: boolean;\n\tdiffText?: string;\n\tpacketId?: string;\n\t/** When set with non-empty runIds and previewOnly false, OA adjudication is invoked. */\n\tclient?: AdaptOrchClient;\n\tregistry?: { get(kind: string): VerifierRegistryEntry };\n\t/** When true, merge deep-wall result into limits / policy flags. */\n\tdeepWall?: boolean;\n\t/** Wave 4-C3b: injected hermetic runner. Completion gated by `deepWallAllowCompletion` + evidence. */\n\tdeepWallRunner?: DeepWallRunnerFn;\n\t/** Must be true for a runner to emit `completed`. */\n\tdeepWallAllowCompletion?: boolean;\n\t/** When set, attach HMAC signed receipt attestation (never log secret). */\n\treceiptSigningSecret?: string;\n}\n\nexport interface EvaluateCorrectnessWallResult {\n\tverdictCard: VerdictCard;\n\treceipt: VerificationReceipt;\n}\n\nexport async function evaluateCorrectnessWall(\n\tparams: EvaluateCorrectnessWallParams,\n): Promise<EvaluateCorrectnessWallResult> {\n\tconst runIds = params.runIds ?? [];\n\tconst previewOnly = params.previewOnly === true;\n\tconst registry = params.registry ?? createVerifierRegistry([]);\n\n\tconst wall = runFastWall({\n\t\tdiffText: params.diffText,\n\t\tapprovedWriteScope: params.approvedWriteScope,\n\t\trunIds,\n\t\tpreviewOnly,\n\t});\n\n\tlet adjudication: Awaited<ReturnType<typeof adjudicate>> | undefined;\n\tconst useOa = runIds.length > 0 && !previewOnly && params.client !== undefined;\n\tif (useOa && params.client !== undefined) {\n\t\tconst request: AdjudicationRequest = {\n\t\t\tdispatch_record_id: params.dispatchRecordId ?? \"b2c-wall\",\n\t\t\tkind: params.kind,\n\t\t\trun_ids: runIds,\n\t\t};\n\t\tadjudication = await adjudicate(request, params.client, registry);\n\t}\n\n\tlet policyFlags = wall.flags;\n\tif (adjudication !== undefined) {\n\t\tpolicyFlags = wall.flags.filter((f) => f !== \"EVIDENCE_DAG_INCOMPLETE\");\n\t}\n\n\tconst provisional = mapToB2C({\n\t\tkind: params.kind,\n\t\tpacketId: params.packetId,\n\t\tdispatchRecordId: params.dispatchRecordId,\n\t\trunIds,\n\t\tpreviewOnly,\n\t\tpolicyFlags,\n\t\tdiffPaths: wall.diffPaths,\n\t\tadjudication,\n\t});\n\n\tconst repairHints = deriveRepairHints({\n\t\tuserVerdict: provisional.verdictCard.verdict,\n\t\tpolicyFlags,\n\t\tadjudicationReasonCode: adjudication?.reason_code,\n\t\tpreviewOnly,\n\t\tdiffPaths: wall.diffPaths,\n\t});\n\n\tconst mapped = mapToB2C({\n\t\tkind: params.kind,\n\t\tpacketId: params.packetId,\n\t\tdispatchRecordId: params.dispatchRecordId,\n\t\trunIds,\n\t\tpreviewOnly,\n\t\tpolicyFlags,\n\t\tdiffPaths: wall.diffPaths,\n\t\tadjudication,\n\t\trepairHints,\n\t});\n\n\tconst verificationDigest = buildVerificationDigest({\n\t\tpatchText: params.diffText,\n\t\tevidenceChunks: runIds.length > 0 ? runIds : undefined,\n\t\twallVersion: CORRECTNESS_WALL_VERSION,\n\t});\n\n\tlet verdictCard = mapped.verdictCard;\n\tlet receipt: VerificationReceipt = {\n\t\t...mapped.receipt,\n\t\tverificationDigest,\n\t\twallVersion: CORRECTNESS_WALL_VERSION,\n\t};\n\n\tconst signingSecret = params.receiptSigningSecret?.trim();\n\tif (signingSecret !== undefined && signingSecret.length > 0 && verificationDigest !== undefined) {\n\t\treceipt = {\n\t\t\t...receipt,\n\t\t\tsignedReceipt: signWallReceipt({\n\t\t\t\tdigest: verificationDigest,\n\t\t\t\twallVersion: CORRECTNESS_WALL_VERSION,\n\t\t\t\tsecret: signingSecret,\n\t\t\t}),\n\t\t};\n\t}\n\n\tif (params.deepWall === true) {\n\t\tconst deep = await runDeepWall({\n\t\t\tkind: params.kind,\n\t\t\trunIds,\n\t\t\tpacketId: params.packetId,\n\t\t\tphase: resolveDeepWallPhaseFromEnv(),\n\t\t\trunner: params.deepWallRunner,\n\t\t\tallowCompletion: params.deepWallAllowCompletion,\n\t\t});\n\t\tconst policyFlags = [...receipt.policyFlags];\n\t\tif (deep.status !== \"completed\") {\n\t\t\tif (!policyFlags.includes(DEEP_WALL_UNAVAILABLE)) {\n\t\t\t\tpolicyFlags.push(DEEP_WALL_UNAVAILABLE);\n\t\t\t}\n\t\t\tif (!isDeepRunnerCompletionAllowed() && !policyFlags.includes(DEEP_RUNNER_NOT_WIRED)) {\n\t\t\t\tpolicyFlags.push(DEEP_RUNNER_NOT_WIRED);\n\t\t\t}\n\t\t}\n\t\tfor (const f of deep.runnerFlags ?? []) {\n\t\t\tif (!policyFlags.includes(f as never)) policyFlags.push(f as never);\n\t\t}\n\t\tconst limitsCode = deep.limits?.[0] ?? verdictCard.limits.code;\n\t\tverdictCard = {\n\t\t\t...verdictCard,\n\t\t\tlimits: {\n\t\t\t\t...verdictCard.limits,\n\t\t\t\trequiresHumanReview: deep.status !== \"completed\",\n\t\t\t\tcode: limitsCode ?? verdictCard.limits.code,\n\t\t\t},\n\t\t\tblocked_reasons: [...new Set([...verdictCard.blocked_reasons, deep.message])],\n\t\t};\n\t\treceipt = {\n\t\t\t...receipt,\n\t\t\tpolicyFlags,\n\t\t\tdeepWallStatus: deep.status,\n\t\t\tdeepWallEvidence: deep.evidence,\n\t\t};\n\t}\n\n\treturn { verdictCard, receipt };\n}\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * In-memory AdaptOrch transport for tests and local evaluation fixtures.
3
+ */
4
+ import { AdaptOrchClient } from "./adaptorch-client.ts";
5
+ export type InMemoryAdaptOrchFixture = Record<string, {
6
+ run: unknown;
7
+ artifacts: unknown;
8
+ traces: unknown;
9
+ }>;
10
+ /** Build an {@link AdaptOrchClient} backed by a per-run_id fixture map. */
11
+ export declare function createInMemoryAdaptOrchClient(fixture: InMemoryAdaptOrchFixture): AdaptOrchClient;
12
+ //# sourceMappingURL=in-memory-adaptorch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-adaptorch.d.ts","sourceRoot":"","sources":["../src/in-memory-adaptorch.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAA2B,MAAM,uBAAuB,CAAC;AAEjF,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAgB7G,2EAA2E;AAC3E,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,wBAAwB,GAAG,eAAe,CAEhG","sourcesContent":["/**\n * In-memory AdaptOrch transport for tests and local evaluation fixtures.\n */\n\nimport { AdaptOrchClient, type AdaptOrchTransport } from \"./adaptorch-client.ts\";\n\nexport type InMemoryAdaptOrchFixture = Record<string, { run: unknown; artifacts: unknown; traces: unknown }>;\n\nfunction makeFakeTransport(byRunId: InMemoryAdaptOrchFixture): AdaptOrchTransport {\n\treturn {\n\t\tasync callTool(name: string, args: Record<string, unknown>) {\n\t\t\tconst runId = args.run_id as string;\n\t\t\tconst fixture = byRunId[runId];\n\t\t\tif (!fixture) throw new Error(`no fixture for run_id ${runId}`);\n\t\t\tif (name === \"adaptorch_get_run\") return fixture.run;\n\t\t\tif (name === \"adaptorch_get_artifacts\") return fixture.artifacts;\n\t\t\tif (name === \"adaptorch_get_traces\") return fixture.traces;\n\t\t\tthrow new Error(`unexpected tool call: ${name}`);\n\t\t},\n\t};\n}\n\n/** Build an {@link AdaptOrchClient} backed by a per-run_id fixture map. */\nexport function createInMemoryAdaptOrchClient(fixture: InMemoryAdaptOrchFixture): AdaptOrchClient {\n\treturn new AdaptOrchClient(makeFakeTransport(fixture));\n}\n"]}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * In-memory AdaptOrch transport for tests and local evaluation fixtures.
3
+ */
4
+ import { AdaptOrchClient } from "./adaptorch-client.js";
5
+ function makeFakeTransport(byRunId) {
6
+ return {
7
+ async callTool(name, args) {
8
+ const runId = args.run_id;
9
+ const fixture = byRunId[runId];
10
+ if (!fixture)
11
+ throw new Error(`no fixture for run_id ${runId}`);
12
+ if (name === "adaptorch_get_run")
13
+ return fixture.run;
14
+ if (name === "adaptorch_get_artifacts")
15
+ return fixture.artifacts;
16
+ if (name === "adaptorch_get_traces")
17
+ return fixture.traces;
18
+ throw new Error(`unexpected tool call: ${name}`);
19
+ },
20
+ };
21
+ }
22
+ /** Build an {@link AdaptOrchClient} backed by a per-run_id fixture map. */
23
+ export function createInMemoryAdaptOrchClient(fixture) {
24
+ return new AdaptOrchClient(makeFakeTransport(fixture));
25
+ }
26
+ //# sourceMappingURL=in-memory-adaptorch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-adaptorch.js","sourceRoot":"","sources":["../src/in-memory-adaptorch.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAA2B,MAAM,uBAAuB,CAAC;AAIjF,SAAS,iBAAiB,CAAC,OAAiC,EAAsB;IACjF,OAAO;QACN,KAAK,CAAC,QAAQ,CAAC,IAAY,EAAE,IAA6B,EAAE;YAC3D,MAAM,KAAK,GAAG,IAAI,CAAC,MAAgB,CAAC;YACpC,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;YAC/B,IAAI,CAAC,OAAO;gBAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,KAAK,EAAE,CAAC,CAAC;YAChE,IAAI,IAAI,KAAK,mBAAmB;gBAAE,OAAO,OAAO,CAAC,GAAG,CAAC;YACrD,IAAI,IAAI,KAAK,yBAAyB;gBAAE,OAAO,OAAO,CAAC,SAAS,CAAC;YACjE,IAAI,IAAI,KAAK,sBAAsB;gBAAE,OAAO,OAAO,CAAC,MAAM,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC;QAAA,CACjD;KACD,CAAC;AAAA,CACF;AAED,2EAA2E;AAC3E,MAAM,UAAU,6BAA6B,CAAC,OAAiC,EAAmB;IACjG,OAAO,IAAI,eAAe,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;AAAA,CACvD","sourcesContent":["/**\n * In-memory AdaptOrch transport for tests and local evaluation fixtures.\n */\n\nimport { AdaptOrchClient, type AdaptOrchTransport } from \"./adaptorch-client.ts\";\n\nexport type InMemoryAdaptOrchFixture = Record<string, { run: unknown; artifacts: unknown; traces: unknown }>;\n\nfunction makeFakeTransport(byRunId: InMemoryAdaptOrchFixture): AdaptOrchTransport {\n\treturn {\n\t\tasync callTool(name: string, args: Record<string, unknown>) {\n\t\t\tconst runId = args.run_id as string;\n\t\t\tconst fixture = byRunId[runId];\n\t\t\tif (!fixture) throw new Error(`no fixture for run_id ${runId}`);\n\t\t\tif (name === \"adaptorch_get_run\") return fixture.run;\n\t\t\tif (name === \"adaptorch_get_artifacts\") return fixture.artifacts;\n\t\t\tif (name === \"adaptorch_get_traces\") return fixture.traces;\n\t\t\tthrow new Error(`unexpected tool call: ${name}`);\n\t\t},\n\t};\n}\n\n/** Build an {@link AdaptOrchClient} backed by a per-run_id fixture map. */\nexport function createInMemoryAdaptOrchClient(fixture: InMemoryAdaptOrchFixture): AdaptOrchClient {\n\treturn new AdaptOrchClient(makeFakeTransport(fixture));\n}\n"]}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Public entry point for `omk-adaptorch-wpl` (stable since 0.91.0).
3
+ *
4
+ * See README.md and `.omk/runs/adaptorch-native-loop-algorithm-20260701/final-part{1,2,3}-*.md`
5
+ * for the design this package implements. Ships as a runtime dependency of the
6
+ * `open-multi-agent-kit` CLI.
7
+ */
8
+ export type { AdaptOrchTransport } from "./adaptorch-client.ts";
9
+ export { AdaptOrchClient } from "./adaptorch-client.ts";
10
+ export type { AdjudicationRequest, AdjudicationResult, PerRunVerdict } from "./adjudicator.ts";
11
+ export { adjudicate } from "./adjudicator.ts";
12
+ export type { AdjudicationReasonCode, CheckResult, VerdictState, VerifierRegistryEntry, } from "./adjudicator-registry.ts";
13
+ export { ADJUDICATION_REASON_CODES, createVerifierRegistry, DEFAULT_VERIFIER, reduceReasonCodes, } from "./adjudicator-registry.ts";
14
+ export type { MapToB2CInput, MapToB2COutput } from "./b2c-mapper.ts";
15
+ export { BATCH1_NO_DOCKER_RUNNER, mapToB2C } from "./b2c-mapper.ts";
16
+ export type { UserRiskLevel, UserVerdict, VerdictCard, VerdictLimits, VerdictNextAction, VerificationReceipt, } from "./b2c-verdict.ts";
17
+ export { B2C_VERDICT_SCHEMA_VERSION } from "./b2c-verdict.ts";
18
+ export type { DeepWallPhase, DeepWallResult, DeepWallRunnerEvidence, DeepWallRunnerFn, DeepWallRunnerResult, DeepWallStatus, DeepWallStubResult, RunDeepWallStubParams, } from "./deep-wall.ts";
19
+ export { DEEP_RUNNER_ERROR, DEEP_RUNNER_EVIDENCE_MISSING, DEEP_RUNNER_NOT_WIRED, DEEP_WALL_UNAVAILABLE, isDeepRunnerCompletionAllowed, resolveDeepWallPhaseFromEnv, runDeepWall, runDeepWallStub, } from "./deep-wall.ts";
20
+ export type { EvaluateCorrectnessWallParams, EvaluateCorrectnessWallResult, } from "./evaluate-correctness-wall.ts";
21
+ export { evaluateCorrectnessWall } from "./evaluate-correctness-wall.ts";
22
+ export type { InMemoryAdaptOrchFixture } from "./in-memory-adaptorch.ts";
23
+ export { createInMemoryAdaptOrchClient } from "./in-memory-adaptorch.ts";
24
+ export type { AdaptOrchCallToolFn, OaTransportMode } from "./live-adaptorch-transport.ts";
25
+ export { createLiveAdaptOrchClient, parseOaTransportModeFromEnv } from "./live-adaptorch-transport.ts";
26
+ export type { NextActionKind, VerdictDisposition } from "./loop.ts";
27
+ export { decideNextTransition, handleAdjudicationFailure, projectVerdictToDisposition, runAdjudicationWithTimeout, } from "./loop.ts";
28
+ export type { CreateMcpIntrospectionTransportOptions, McpIntrospectionMode, } from "./mcp-introspection-transport.ts";
29
+ export { createMcpIntrospectionClient } from "./mcp-introspection-transport.ts";
30
+ export type { PolicyFlag } from "./policy-wall.ts";
31
+ export { POLICY_FLAG, parseDiffPaths, pathMatchesApprovedScope, runFastWall, scanDiffLinesForSecrets, } from "./policy-wall.ts";
32
+ export type { SignedWallReceipt, SignWallReceiptInput, VerifyWallReceiptInput } from "./receipt-signature.ts";
33
+ export { signWallReceipt, verifyWallReceipt } from "./receipt-signature.ts";
34
+ export type { BuildRegeneratePacketInput, RegeneratePacket } from "./regenerate-packet.ts";
35
+ export { buildRegeneratePacket } from "./regenerate-packet.ts";
36
+ export type { RepairBudgetState } from "./repair-budget.ts";
37
+ export { capRepairHints, parseRepairBudget, shouldOfferRepair } from "./repair-budget.ts";
38
+ export type { RepairHintInput } from "./repair-loop.ts";
39
+ export { deriveRepairHints } from "./repair-loop.ts";
40
+ export type { VerificationDigest, VerificationDigestInput, WallReceiptMeta, } from "./signed-receipt.ts";
41
+ export { buildVerificationDigest } from "./signed-receipt.ts";
42
+ export { applyTransition, canTransition, isTerminalState, requiresHumanApproval } from "./state-machine.ts";
43
+ export type { CardinalityMode, DispatchRecord, LoopConfig, LoopTerminationCondition, TopologyClassification, TransitionLogEntry, WorkPacket, WorkPacketState, } from "./types.ts";
44
+ export { ADJUDICATIONS_DIR, LOOP_STATE_FILE, PACKET_INDEX_FILE, PACKETS_DIR, RUN_MAP_FILE } from "./types.ts";
45
+ export { CORRECTNESS_WALL_VERSION } from "./wall-meta.ts";
46
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EACX,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,qBAAqB,GACrB,MA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O,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["/**\n * Public entry point for `omk-adaptorch-wpl` (stable since 0.91.0).\n *\n * See README.md and `.omk/runs/adaptorch-native-loop-algorithm-20260701/final-part{1,2,3}-*.md`\n * for the design this package implements. Ships as a runtime dependency of the\n * `open-multi-agent-kit` CLI.\n */\n\nexport type { AdaptOrchTransport } from \"./adaptorch-client.ts\";\nexport { AdaptOrchClient } from \"./adaptorch-client.ts\";\nexport type { AdjudicationRequest, AdjudicationResult, PerRunVerdict } from \"./adjudicator.ts\";\nexport { adjudicate } from \"./adjudicator.ts\";\nexport type {\n\tAdjudicationReasonCode,\n\tCheckResult,\n\tVerdictState,\n\tVerifierRegistryEntry,\n} from \"./adjudicator-registry.ts\";\nexport {\n\tADJUDICATION_REASON_CODES,\n\tcreateVerifierRegistry,\n\tDEFAULT_VERIFIER,\n\treduceReasonCodes,\n} from \"./adjudicator-registry.ts\";\nexport type { MapToB2CInput, MapToB2COutput } from \"./b2c-mapper.ts\";\nexport { BATCH1_NO_DOCKER_RUNNER, mapToB2C } from \"./b2c-mapper.ts\";\nexport type {\n\tUserRiskLevel,\n\tUserVerdict,\n\tVerdictCard,\n\tVerdictLimits,\n\tVerdictNextAction,\n\tVerificationReceipt,\n} from \"./b2c-verdict.ts\";\nexport { B2C_VERDICT_SCHEMA_VERSION } from \"./b2c-verdict.ts\";\nexport type {\n\tDeepWallPhase,\n\tDeepWallResult,\n\tDeepWallRunnerEvidence,\n\tDeepWallRunnerFn,\n\tDeepWallRunnerResult,\n\tDeepWallStatus,\n\tDeepWallStubResult,\n\tRunDeepWallStubParams,\n} from \"./deep-wall.ts\";\nexport {\n\tDEEP_RUNNER_ERROR,\n\tDEEP_RUNNER_EVIDENCE_MISSING,\n\tDEEP_RUNNER_NOT_WIRED,\n\tDEEP_WALL_UNAVAILABLE,\n\tisDeepRunnerCompletionAllowed,\n\tresolveDeepWallPhaseFromEnv,\n\trunDeepWall,\n\trunDeepWallStub,\n} from \"./deep-wall.ts\";\nexport type {\n\tEvaluateCorrectnessWallParams,\n\tEvaluateCorrectnessWallResult,\n} from \"./evaluate-correctness-wall.ts\";\nexport { evaluateCorrectnessWall } from \"./evaluate-correctness-wall.ts\";\nexport type { InMemoryAdaptOrchFixture } from \"./in-memory-adaptorch.ts\";\nexport { createInMemoryAdaptOrchClient } from \"./in-memory-adaptorch.ts\";\nexport type { AdaptOrchCallToolFn, OaTransportMode } from \"./live-adaptorch-transport.ts\";\nexport { createLiveAdaptOrchClient, parseOaTransportModeFromEnv } from \"./live-adaptorch-transport.ts\";\nexport type { NextActionKind, VerdictDisposition } from \"./loop.ts\";\nexport {\n\tdecideNextTransition,\n\thandleAdjudicationFailure,\n\tprojectVerdictToDisposition,\n\trunAdjudicationWithTimeout,\n} from \"./loop.ts\";\nexport type {\n\tCreateMcpIntrospectionTransportOptions,\n\tMcpIntrospectionMode,\n} from \"./mcp-introspection-transport.ts\";\nexport { createMcpIntrospectionClient } from \"./mcp-introspection-transport.ts\";\nexport type { PolicyFlag } from \"./policy-wall.ts\";\nexport {\n\tPOLICY_FLAG,\n\tparseDiffPaths,\n\tpathMatchesApprovedScope,\n\trunFastWall,\n\tscanDiffLinesForSecrets,\n} from \"./policy-wall.ts\";\nexport type { SignedWallReceipt, SignWallReceiptInput, VerifyWallReceiptInput } from \"./receipt-signature.ts\";\nexport { signWallReceipt, verifyWallReceipt } from \"./receipt-signature.ts\";\nexport type { BuildRegeneratePacketInput, RegeneratePacket } from \"./regenerate-packet.ts\";\nexport { buildRegeneratePacket } from \"./regenerate-packet.ts\";\nexport type { RepairBudgetState } from \"./repair-budget.ts\";\nexport { capRepairHints, parseRepairBudget, shouldOfferRepair } from \"./repair-budget.ts\";\nexport type { RepairHintInput } from \"./repair-loop.ts\";\nexport { deriveRepairHints } from \"./repair-loop.ts\";\nexport type {\n\tVerificationDigest,\n\tVerificationDigestInput,\n\tWallReceiptMeta,\n} from \"./signed-receipt.ts\";\nexport { buildVerificationDigest } from \"./signed-receipt.ts\";\nexport { applyTransition, canTransition, isTerminalState, requiresHumanApproval } from \"./state-machine.ts\";\nexport type {\n\tCardinalityMode,\n\tDispatchRecord,\n\tLoopConfig,\n\tLoopTerminationCondition,\n\tTopologyClassification,\n\tTransitionLogEntry,\n\tWorkPacket,\n\tWorkPacketState,\n} from \"./types.ts\";\nexport { ADJUDICATIONS_DIR, LOOP_STATE_FILE, PACKET_INDEX_FILE, PACKETS_DIR, RUN_MAP_FILE } from \"./types.ts\";\nexport { CORRECTNESS_WALL_VERSION } from \"./wall-meta.ts\";\n"]}
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Public entry point for `omk-adaptorch-wpl` (stable since 0.91.0).
3
+ *
4
+ * See README.md and `.omk/runs/adaptorch-native-loop-algorithm-20260701/final-part{1,2,3}-*.md`
5
+ * for the design this package implements. Ships as a runtime dependency of the
6
+ * `open-multi-agent-kit` CLI.
7
+ */
8
+ export { AdaptOrchClient } from "./adaptorch-client.js";
9
+ export { adjudicate } from "./adjudicator.js";
10
+ export { ADJUDICATION_REASON_CODES, createVerifierRegistry, DEFAULT_VERIFIER, reduceReasonCodes, } from "./adjudicator-registry.js";
11
+ export { BATCH1_NO_DOCKER_RUNNER, mapToB2C } from "./b2c-mapper.js";
12
+ export { B2C_VERDICT_SCHEMA_VERSION } from "./b2c-verdict.js";
13
+ export { DEEP_RUNNER_ERROR, DEEP_RUNNER_EVIDENCE_MISSING, DEEP_RUNNER_NOT_WIRED, DEEP_WALL_UNAVAILABLE, isDeepRunnerCompletionAllowed, resolveDeepWallPhaseFromEnv, runDeepWall, runDeepWallStub, } from "./deep-wall.js";
14
+ export { evaluateCorrectnessWall } from "./evaluate-correctness-wall.js";
15
+ export { createInMemoryAdaptOrchClient } from "./in-memory-adaptorch.js";
16
+ export { createLiveAdaptOrchClient, parseOaTransportModeFromEnv } from "./live-adaptorch-transport.js";
17
+ export { decideNextTransition, handleAdjudicationFailure, projectVerdictToDisposition, runAdjudicationWithTimeout, } from "./loop.js";
18
+ export { createMcpIntrospectionClient } from "./mcp-introspection-transport.js";
19
+ export { POLICY_FLAG, parseDiffPaths, pathMatchesApprovedScope, runFastWall, scanDiffLinesForSecrets, } from "./policy-wall.js";
20
+ export { signWallReceipt, verifyWallReceipt } from "./receipt-signature.js";
21
+ export { buildRegeneratePacket } from "./regenerate-packet.js";
22
+ export { capRepairHints, parseRepairBudget, shouldOfferRepair } from "./repair-budget.js";
23
+ export { deriveRepairHints } from "./repair-loop.js";
24
+ export { buildVerificationDigest } from "./signed-receipt.js";
25
+ export { applyTransition, canTransition, isTerminalState, requiresHumanApproval } from "./state-machine.js";
26
+ export { ADJUDICATIONS_DIR, LOOP_STATE_FILE, PACKET_INDEX_FILE, PACKETS_DIR, RUN_MAP_FILE } from "./types.js";
27
+ export { CORRECTNESS_WALL_VERSION } from "./wall-meta.js";
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAO9C,OAAO,EACN,yBAAyB,EACzB,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,GACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AASpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAW9D,OAAO,EACN,iBAAiB,EACjB,4BAA4B,EAC5B,qBAAqB,EACrB,qBAAqB,EACrB,6BAA6B,EAC7B,2BAA2B,EAC3B,WAAW,EACX,eAAe,GACf,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAEvG,OAAO,EACN,oBAAoB,EACpB,yBAAyB,EACzB,2BAA2B,EAC3B,0BAA0B,GAC1B,MAAM,WAAW,CAAC;AAKnB,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAEhF,OAAO,EACN,WAAW,EACX,cAAc,EACd,wBAAwB,EACxB,WAAW,EACX,uBAAuB,GACvB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAMrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAW5G,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC9G,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["/**\n * Public entry point for `omk-adaptorch-wpl` (stable since 0.91.0).\n *\n * See README.md and `.omk/runs/adaptorch-native-loop-algorithm-20260701/final-part{1,2,3}-*.md`\n * for the design this package implements. Ships as a runtime dependency of the\n * `open-multi-agent-kit` CLI.\n */\n\nexport type { AdaptOrchTransport } from \"./adaptorch-client.ts\";\nexport { AdaptOrchClient } from \"./adaptorch-client.ts\";\nexport type { AdjudicationRequest, AdjudicationResult, PerRunVerdict } from \"./adjudicator.ts\";\nexport { adjudicate } from \"./adjudicator.ts\";\nexport type {\n\tAdjudicationReasonCode,\n\tCheckResult,\n\tVerdictState,\n\tVerifierRegistryEntry,\n} from \"./adjudicator-registry.ts\";\nexport {\n\tADJUDICATION_REASON_CODES,\n\tcreateVerifierRegistry,\n\tDEFAULT_VERIFIER,\n\treduceReasonCodes,\n} from \"./adjudicator-registry.ts\";\nexport type { MapToB2CInput, MapToB2COutput } from \"./b2c-mapper.ts\";\nexport { BATCH1_NO_DOCKER_RUNNER, mapToB2C } from \"./b2c-mapper.ts\";\nexport type {\n\tUserRiskLevel,\n\tUserVerdict,\n\tVerdictCard,\n\tVerdictLimits,\n\tVerdictNextAction,\n\tVerificationReceipt,\n} from \"./b2c-verdict.ts\";\nexport { B2C_VERDICT_SCHEMA_VERSION } from \"./b2c-verdict.ts\";\nexport type {\n\tDeepWallPhase,\n\tDeepWallResult,\n\tDeepWallRunnerEvidence,\n\tDeepWallRunnerFn,\n\tDeepWallRunnerResult,\n\tDeepWallStatus,\n\tDeepWallStubResult,\n\tRunDeepWallStubParams,\n} from \"./deep-wall.ts\";\nexport {\n\tDEEP_RUNNER_ERROR,\n\tDEEP_RUNNER_EVIDENCE_MISSING,\n\tDEEP_RUNNER_NOT_WIRED,\n\tDEEP_WALL_UNAVAILABLE,\n\tisDeepRunnerCompletionAllowed,\n\tresolveDeepWallPhaseFromEnv,\n\trunDeepWall,\n\trunDeepWallStub,\n} from \"./deep-wall.ts\";\nexport type {\n\tEvaluateCorrectnessWallParams,\n\tEvaluateCorrectnessWallResult,\n} from \"./evaluate-correctness-wall.ts\";\nexport { evaluateCorrectnessWall } from \"./evaluate-correctness-wall.ts\";\nexport type { InMemoryAdaptOrchFixture } from \"./in-memory-adaptorch.ts\";\nexport { createInMemoryAdaptOrchClient } from \"./in-memory-adaptorch.ts\";\nexport type { AdaptOrchCallToolFn, OaTransportMode } from \"./live-adaptorch-transport.ts\";\nexport { createLiveAdaptOrchClient, parseOaTransportModeFromEnv } from \"./live-adaptorch-transport.ts\";\nexport type { NextActionKind, VerdictDisposition } from \"./loop.ts\";\nexport {\n\tdecideNextTransition,\n\thandleAdjudicationFailure,\n\tprojectVerdictToDisposition,\n\trunAdjudicationWithTimeout,\n} from \"./loop.ts\";\nexport type {\n\tCreateMcpIntrospectionTransportOptions,\n\tMcpIntrospectionMode,\n} from \"./mcp-introspection-transport.ts\";\nexport { createMcpIntrospectionClient } from \"./mcp-introspection-transport.ts\";\nexport type { PolicyFlag } from \"./policy-wall.ts\";\nexport {\n\tPOLICY_FLAG,\n\tparseDiffPaths,\n\tpathMatchesApprovedScope,\n\trunFastWall,\n\tscanDiffLinesForSecrets,\n} from \"./policy-wall.ts\";\nexport type { SignedWallReceipt, SignWallReceiptInput, VerifyWallReceiptInput } from \"./receipt-signature.ts\";\nexport { signWallReceipt, verifyWallReceipt } from \"./receipt-signature.ts\";\nexport type { BuildRegeneratePacketInput, RegeneratePacket } from \"./regenerate-packet.ts\";\nexport { buildRegeneratePacket } from \"./regenerate-packet.ts\";\nexport type { RepairBudgetState } from \"./repair-budget.ts\";\nexport { capRepairHints, parseRepairBudget, shouldOfferRepair } from \"./repair-budget.ts\";\nexport type { RepairHintInput } from \"./repair-loop.ts\";\nexport { deriveRepairHints } from \"./repair-loop.ts\";\nexport type {\n\tVerificationDigest,\n\tVerificationDigestInput,\n\tWallReceiptMeta,\n} from \"./signed-receipt.ts\";\nexport { buildVerificationDigest } from \"./signed-receipt.ts\";\nexport { applyTransition, canTransition, isTerminalState, requiresHumanApproval } from \"./state-machine.ts\";\nexport type {\n\tCardinalityMode,\n\tDispatchRecord,\n\tLoopConfig,\n\tLoopTerminationCondition,\n\tTopologyClassification,\n\tTransitionLogEntry,\n\tWorkPacket,\n\tWorkPacketState,\n} from \"./types.ts\";\nexport { ADJUDICATIONS_DIR, LOOP_STATE_FILE, PACKET_INDEX_FILE, PACKETS_DIR, RUN_MAP_FILE } from \"./types.ts\";\nexport { CORRECTNESS_WALL_VERSION } from \"./wall-meta.ts\";\n"]}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Live AdaptOrch MCP transport adapter (Wave 4) — inject session `callTool` at the boundary.
3
+ */
4
+ import { AdaptOrchClient, type AdaptOrchTransport } from "./adaptorch-client.ts";
5
+ export type AdaptOrchCallToolFn = AdaptOrchTransport["callTool"];
6
+ /**
7
+ * Build an {@link AdaptOrchClient} that forwards introspection (and other) tools to MCP.
8
+ * Caller supplies `callTool` from an MCP SDK or harness; this package does not open network I/O.
9
+ */
10
+ export declare function createLiveAdaptOrchClient(callTool: AdaptOrchCallToolFn): AdaptOrchClient;
11
+ /** Env `OMK_WALL_OA_TRANSPORT`: fixture (default) | mcp | live (alias of mcp). */
12
+ export type OaTransportMode = "fixture" | "mcp";
13
+ export declare function parseOaTransportModeFromEnv(): OaTransportMode;
14
+ //# sourceMappingURL=live-adaptorch-transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-adaptorch-transport.d.ts","sourceRoot":"","sources":["../src/live-adaptorch-transport.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEjF,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;AAEjE;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,eAAe,CAGxF;AAED,kFAAkF;AAClF,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,KAAK,CAAC;AAEhD,wBAAgB,2BAA2B,IAAI,eAAe,CAI7D","sourcesContent":["/**\n * Live AdaptOrch MCP transport adapter (Wave 4) — inject session `callTool` at the boundary.\n */\n\nimport { AdaptOrchClient, type AdaptOrchTransport } from \"./adaptorch-client.ts\";\n\nexport type AdaptOrchCallToolFn = AdaptOrchTransport[\"callTool\"];\n\n/**\n * Build an {@link AdaptOrchClient} that forwards introspection (and other) tools to MCP.\n * Caller supplies `callTool` from an MCP SDK or harness; this package does not open network I/O.\n */\nexport function createLiveAdaptOrchClient(callTool: AdaptOrchCallToolFn): AdaptOrchClient {\n\tconst transport: AdaptOrchTransport = { callTool };\n\treturn new AdaptOrchClient(transport);\n}\n\n/** Env `OMK_WALL_OA_TRANSPORT`: fixture (default) | mcp | live (alias of mcp). */\nexport type OaTransportMode = \"fixture\" | \"mcp\";\n\nexport function parseOaTransportModeFromEnv(): OaTransportMode {\n\tconst raw = process.env.OMK_WALL_OA_TRANSPORT?.trim().toLowerCase();\n\tif (raw === \"mcp\" || raw === \"live\") return \"mcp\";\n\treturn \"fixture\";\n}\n"]}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Live AdaptOrch MCP transport adapter (Wave 4) — inject session `callTool` at the boundary.
3
+ */
4
+ import { AdaptOrchClient } from "./adaptorch-client.js";
5
+ /**
6
+ * Build an {@link AdaptOrchClient} that forwards introspection (and other) tools to MCP.
7
+ * Caller supplies `callTool` from an MCP SDK or harness; this package does not open network I/O.
8
+ */
9
+ export function createLiveAdaptOrchClient(callTool) {
10
+ const transport = { callTool };
11
+ return new AdaptOrchClient(transport);
12
+ }
13
+ export function parseOaTransportModeFromEnv() {
14
+ const raw = process.env.OMK_WALL_OA_TRANSPORT?.trim().toLowerCase();
15
+ if (raw === "mcp" || raw === "live")
16
+ return "mcp";
17
+ return "fixture";
18
+ }
19
+ //# sourceMappingURL=live-adaptorch-transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-adaptorch-transport.js","sourceRoot":"","sources":["../src/live-adaptorch-transport.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAA2B,MAAM,uBAAuB,CAAC;AAIjF;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAA6B,EAAmB;IACzF,MAAM,SAAS,GAAuB,EAAE,QAAQ,EAAE,CAAC;IACnD,OAAO,IAAI,eAAe,CAAC,SAAS,CAAC,CAAC;AAAA,CACtC;AAKD,MAAM,UAAU,2BAA2B,GAAoB;IAC9D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACpE,IAAI,GAAG,KAAK,KAAK,IAAI,GAAG,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IAClD,OAAO,SAAS,CAAC;AAAA,CACjB","sourcesContent":["/**\n * Live AdaptOrch MCP transport adapter (Wave 4) — inject session `callTool` at the boundary.\n */\n\nimport { AdaptOrchClient, type AdaptOrchTransport } from \"./adaptorch-client.ts\";\n\nexport type AdaptOrchCallToolFn = AdaptOrchTransport[\"callTool\"];\n\n/**\n * Build an {@link AdaptOrchClient} that forwards introspection (and other) tools to MCP.\n * Caller supplies `callTool` from an MCP SDK or harness; this package does not open network I/O.\n */\nexport function createLiveAdaptOrchClient(callTool: AdaptOrchCallToolFn): AdaptOrchClient {\n\tconst transport: AdaptOrchTransport = { callTool };\n\treturn new AdaptOrchClient(transport);\n}\n\n/** Env `OMK_WALL_OA_TRANSPORT`: fixture (default) | mcp | live (alias of mcp). */\nexport type OaTransportMode = \"fixture\" | \"mcp\";\n\nexport function parseOaTransportModeFromEnv(): OaTransportMode {\n\tconst raw = process.env.OMK_WALL_OA_TRANSPORT?.trim().toLowerCase();\n\tif (raw === \"mcp\" || raw === \"live\") return \"mcp\";\n\treturn \"fixture\";\n}\n"]}
package/dist/loop.d.ts ADDED
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Verdict-to-disposition integration layer (Part 3, `final-part3-integration.md`).
3
+ *
4
+ * This file implements exactly the bridge Part 3 defines between Part 1 (core algorithm,
5
+ * `final-part1-core-algorithm.md`) and Part 2 (verification layer,
6
+ * `final-part2-verification-layer.md`): projecting Part 2's five-state record-level
7
+ * `AdjudicationResult.verdict` onto Part 1's packet disposition vocabulary, and the two
8
+ * distinct failure-handling paths (`VERIFIER-ERROR` vs. `ADJUDICATION_FAILED`) Part 3's
9
+ * "VERIFIER-ERROR vs. ADJUDICATION_FAILED" section keeps separate.
10
+ *
11
+ * What is implemented here (Part 3 §1, §2 note, §3 note):
12
+ * - {@link projectVerdictToDisposition} - Part 3 §1's mapping table from a *returned*
13
+ * `AdjudicationResult` to a `{ targetState, nextActionKind }` disposition.
14
+ * - {@link runAdjudicationWithTimeout} - the timeout/try-catch wrapper around `adjudicate()`
15
+ * itself (Part 1 §2 state 9 / Part 3's "ADJUDICATION_FAILED" trigger condition), so a hung
16
+ * or throwing `adjudicate()` call never escapes uncaught and never produces a verdict to
17
+ * project in the first place.
18
+ * - {@link decideNextTransition} - the `DECLINED -> {RETRY_QUEUED | CLOSED | ESCALATED}`
19
+ * branch (Part 1 §2/§4, Part 3 §1), keyed on the per-packet attempt budget.
20
+ * - {@link handleAdjudicationFailure} - the `ADJUDICATION_FAILED -> {UNDER_REVIEW |
21
+ * ESCALATED}` branch (Part 1 §2 state 9), keyed on a *separate* bounded adjudication-call
22
+ * retry counter, never the packet's attempt/dispatch budget.
23
+ *
24
+ * What is explicitly out of scope for this file, per the design docs' own module boundaries
25
+ * (Part 1's introduction puts the integration boundary itself out of its scope; Part 3 §2
26
+ * assigns request assembly to the core-algorithm/loop side as an already-specified
27
+ * responsibility distinct from this projection):
28
+ * - The end-to-end AdaptOrch dispatch loop: `DRAFTED -> ROUTED -> AWAITING_APPROVAL ->
29
+ * DISPATCHED -> ACTIVE`, topology routing, actual `adaptorch_run` submission, and polling
30
+ * via `adaptorch_get_run`/reconciliation sweeps.
31
+ * - Assembling an `AdjudicationRequest` from a Work Packet's `dispatch_records[]` (Part 3
32
+ * §2's "one minor shape note") - callers of {@link runAdjudicationWithTimeout} supply an
33
+ * already-built `AdjudicationRequest`.
34
+ * - The on-disk persistence layer (`packet_index.json`, `run_map.json`, `loop_state.json`,
35
+ * the `adjudications/` archive, Part 1 §7) - the functions here are pure/async-pure and
36
+ * return decisions; they do not read or write any of those files themselves.
37
+ */
38
+ import type { AdaptOrchClient } from "./adaptorch-client.ts";
39
+ import type { AdjudicationRequest, AdjudicationResult } from "./adjudicator.ts";
40
+ import type { VerifierRegistryEntry } from "./adjudicator-registry.ts";
41
+ import type { WorkPacket, WorkPacketState } from "./types.ts";
42
+ /**
43
+ * Part 1 §6's `next_action` vocabulary, restricted to the values Part 3 §1's projection
44
+ * table actually produces (`'none'` covers the `CONFIRMED` row, which carries no
45
+ * `next_action` of its own).
46
+ */
47
+ export type NextActionKind = "retry_same_topology" | "reroute" | "escalate" | "none";
48
+ /**
49
+ * The projected disposition for a single record-level `AdjudicationResult` (Part 3 §1):
50
+ * the Part 1 §2 state the packet should move towards, and which further-attempt behavior
51
+ * (if any) that implies.
52
+ */
53
+ export interface VerdictDisposition {
54
+ targetState: WorkPacketState;
55
+ nextActionKind: NextActionKind;
56
+ }
57
+ /**
58
+ * Projects a Part 2 record-level {@link AdjudicationResult} onto a Part 1 packet
59
+ * disposition, per Part 3 §1's mapping table exactly:
60
+ *
61
+ * | verdict | condition | targetState | nextActionKind |
62
+ * |---|---|---|---|
63
+ * | `CONFIRMED` | - | `CONFIRMED` | `none` |
64
+ * | `CORROBORATED-FAILURE` | - | `DECLINED` | `retry_same_topology` |
65
+ * | `CONTRADICTED` | `reason_code` = `SCOPE_VIOLATION` | `DECLINED` | `escalate` |
66
+ * | `CONTRADICTED` | `reason_code` ∈ {`SCHEMA_DRIFT`, `CONTENT_CHECK_FAILED`} AND `packet.retry_count >= 1` | `DECLINED` | `reroute` |
67
+ * | `CONTRADICTED` | any other `reason_code` | `DECLINED` | `retry_same_topology` |
68
+ * | `INDETERMINATE` | - | `DECLINED` | `escalate` |
69
+ * | `VERIFIER-ERROR` | - | `DECLINED` | `escalate` |
70
+ *
71
+ * Branching is driven exclusively by the structured `reason_code`
72
+ * ({@link CONTRADICTED_DISPOSITION_CLASS}); the free-text `reason` is never inspected, so
73
+ * incidental wording in a check's human-readable explanation (e.g. "scoped variable")
74
+ * can neither trigger a false escalation nor mask a real one.
75
+ *
76
+ * `VERIFIER-ERROR` vs. `ADJUDICATION_FAILED` (Part 3's dedicated section, restated here
77
+ * because callers of this function must not conflate the two): `VERIFIER-ERROR` is a verdict
78
+ * the OA *returned normally* - `adjudicate()` completed, produced a full
79
+ * {@link AdjudicationResult}, and that result's own content says the OA's checks could not be
80
+ * trusted for this record. This function only ever runs on such a completed result, so it
81
+ * only ever needs to route `VERIFIER-ERROR` to `escalate` - never to a retry, and never
82
+ * through `ADJUDICATION_FAILED`. `ADJUDICATION_FAILED` (Part 1 §2 state 9), by contrast, is
83
+ * not a verdict at all: it is what happens when `adjudicate()` itself throws or times out and
84
+ * *never returns a verdict in the first place* - there is no `AdjudicationResult` for this
85
+ * function to project, because the mapping's input does not exist. That case is handled
86
+ * separately by {@link runAdjudicationWithTimeout} (detecting the failure) and
87
+ * {@link handleAdjudicationFailure} (deciding the packet's next state), never by this
88
+ * function.
89
+ *
90
+ * Declared `async` for interface consistency with the rest of the verdict-handling pipeline
91
+ * (all of whose other entry points are asynchronous); the projection logic itself is pure and
92
+ * synchronous.
93
+ */
94
+ export declare function projectVerdictToDisposition(result: AdjudicationResult, packet: WorkPacket): Promise<VerdictDisposition>;
95
+ /**
96
+ * Runs `adjudicate()` under both a timeout and a try/catch, per Part 1 §2 state 9 / Part 3's
97
+ * "ADJUDICATION_FAILED" trigger condition. Returns `{ ok: true, result }` when `adjudicate()`
98
+ * returns a verdict within `timeoutMs`; returns `{ ok: false, error }` if it throws, rejects,
99
+ * or does not settle before the timeout - this is the ADJUDICATION_FAILED condition, and the
100
+ * only way this function reports failure. It never lets a hung or throwing `adjudicate()`
101
+ * call escape uncaught.
102
+ *
103
+ * Note the distinction from {@link projectVerdictToDisposition}'s `VERIFIER-ERROR` handling:
104
+ * a `VERIFIER-ERROR` result here still comes back as `{ ok: true, result }` (a verdict was
105
+ * produced), and must be routed through `projectVerdictToDisposition`, not through
106
+ * {@link handleAdjudicationFailure}.
107
+ */
108
+ export declare function runAdjudicationWithTimeout(request: AdjudicationRequest, client: AdaptOrchClient, registry: {
109
+ get(kind: string): VerifierRegistryEntry;
110
+ }, timeoutMs: number): Promise<{
111
+ ok: true;
112
+ result: AdjudicationResult;
113
+ } | {
114
+ ok: false;
115
+ error: string;
116
+ }>;
117
+ /**
118
+ * Decides the packet's next state given an already-projected {@link VerdictDisposition}
119
+ * (Part 1 §2/§4, Part 3 §1's `DECLINED -> {RETRY_QUEUED | CLOSED | ESCALATED}` branch). Pure
120
+ * and side-effect free; does not itself call {@link applyTransition} from
121
+ * `state-machine.ts` - callers apply the returned state via that function.
122
+ *
123
+ * - `nextActionKind === 'escalate'` always wins, regardless of remaining budget (Part 3 §1:
124
+ * escalation "takes priority over the attempt-budget check below, regardless of whether
125
+ * budget remains").
126
+ * - `targetState === 'CONFIRMED'` returns `'CONFIRMED'` directly; the caller is responsible
127
+ * for the separate `CONFIRMED -> CLOSED` transition (Part 1's success-close path), which is
128
+ * not this function's concern.
129
+ * - Otherwise (`retry_same_topology` or `reroute`), the per-packet attempt budget (Part 1 §4)
130
+ * decides between `RETRY_QUEUED` (budget remains) and `CLOSED` (budget exhausted -
131
+ * abandoned).
132
+ */
133
+ export declare function decideNextTransition(packet: WorkPacket, disposition: VerdictDisposition): WorkPacketState;
134
+ /**
135
+ * Decides the packet's next state after an `ADJUDICATION_FAILED` outcome (Part 1 §2 state 9;
136
+ * see {@link runAdjudicationWithTimeout} for how that outcome is detected). This is the
137
+ * *other* failure surface from `VERIFIER-ERROR` - there is no `AdjudicationResult` here, so
138
+ * this function is never fed through {@link projectVerdictToDisposition} or
139
+ * {@link decideNextTransition}.
140
+ *
141
+ * `adjudicationCallAttempts` / `maxAdjudicationCallAttempts` track a bounded counter for
142
+ * retrying the `adjudicate()` *call itself* - distinct from, and never conflated with, the
143
+ * packet's `retry_count` / `attempt_budget.max_dispatch_attempts` (Part 1 §7 notes this as a
144
+ * separate persisted field, `adjudication_retry_count`, for exactly this purpose). Returns
145
+ * `'UNDER_REVIEW'` (retry the call, against the already-pulled evidence) while the counter has
146
+ * not been exhausted, else `'ESCALATED'` once it has.
147
+ */
148
+ export declare function handleAdjudicationFailure(packet: WorkPacket, adjudicationCallAttempts: number, maxAdjudicationCallAttempts: number): WorkPacketState;
149
+ //# sourceMappingURL=loop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../src/loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,KAAK,EAA0B,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAuC9D;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,qBAAqB,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;AAErF;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,WAAW,EAAE,eAAe,CAAC;IAC7B,cAAc,EAAE,cAAc,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAsB,2BAA2B,CAChD,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,UAAU,GAChB,OAAO,CAAC,kBAAkB,CAAC,CAwC7B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,0BAA0B,CAC/C,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE;IAAE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAAA;CAAE,EACtD,SAAS,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAiBlF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,kBAAkB,GAAG,eAAe,CAUzG;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACxC,MAAM,EAAE,UAAU,EAClB,wBAAwB,EAAE,MAAM,EAChC,2BAA2B,EAAE,MAAM,GACjC,eAAe,CAGjB","sourcesContent":["/**\n * Verdict-to-disposition integration layer (Part 3, `final-part3-integration.md`).\n *\n * This file implements exactly the bridge Part 3 defines between Part 1 (core algorithm,\n * `final-part1-core-algorithm.md`) and Part 2 (verification layer,\n * `final-part2-verification-layer.md`): projecting Part 2's five-state record-level\n * `AdjudicationResult.verdict` onto Part 1's packet disposition vocabulary, and the two\n * distinct failure-handling paths (`VERIFIER-ERROR` vs. `ADJUDICATION_FAILED`) Part 3's\n * \"VERIFIER-ERROR vs. ADJUDICATION_FAILED\" section keeps separate.\n *\n * What is implemented here (Part 3 §1, §2 note, §3 note):\n * - {@link projectVerdictToDisposition} - Part 3 §1's mapping table from a *returned*\n * `AdjudicationResult` to a `{ targetState, nextActionKind }` disposition.\n * - {@link runAdjudicationWithTimeout} - the timeout/try-catch wrapper around `adjudicate()`\n * itself (Part 1 §2 state 9 / Part 3's \"ADJUDICATION_FAILED\" trigger condition), so a hung\n * or throwing `adjudicate()` call never escapes uncaught and never produces a verdict to\n * project in the first place.\n * - {@link decideNextTransition} - the `DECLINED -> {RETRY_QUEUED | CLOSED | ESCALATED}`\n * branch (Part 1 §2/§4, Part 3 §1), keyed on the per-packet attempt budget.\n * - {@link handleAdjudicationFailure} - the `ADJUDICATION_FAILED -> {UNDER_REVIEW |\n * ESCALATED}` branch (Part 1 §2 state 9), keyed on a *separate* bounded adjudication-call\n * retry counter, never the packet's attempt/dispatch budget.\n *\n * What is explicitly out of scope for this file, per the design docs' own module boundaries\n * (Part 1's introduction puts the integration boundary itself out of its scope; Part 3 §2\n * assigns request assembly to the core-algorithm/loop side as an already-specified\n * responsibility distinct from this projection):\n * - The end-to-end AdaptOrch dispatch loop: `DRAFTED -> ROUTED -> AWAITING_APPROVAL ->\n * DISPATCHED -> ACTIVE`, topology routing, actual `adaptorch_run` submission, and polling\n * via `adaptorch_get_run`/reconciliation sweeps.\n * - Assembling an `AdjudicationRequest` from a Work Packet's `dispatch_records[]` (Part 3\n * §2's \"one minor shape note\") - callers of {@link runAdjudicationWithTimeout} supply an\n * already-built `AdjudicationRequest`.\n * - The on-disk persistence layer (`packet_index.json`, `run_map.json`, `loop_state.json`,\n * the `adjudications/` archive, Part 1 §7) - the functions here are pure/async-pure and\n * return decisions; they do not read or write any of those files themselves.\n */\n\nimport type { AdaptOrchClient } from \"./adaptorch-client.ts\";\nimport type { AdjudicationRequest, AdjudicationResult } from \"./adjudicator.ts\";\nimport { adjudicate } from \"./adjudicator.ts\";\nimport type { AdjudicationReasonCode, VerifierRegistryEntry } from \"./adjudicator-registry.ts\";\nimport type { WorkPacket, WorkPacketState } from \"./types.ts\";\n\n/**\n * How a `CONTRADICTED` verdict with a given reason code is dispositioned (Part 3 §1's\n * three CONTRADICTED rows). Kept as a named class so {@link CONTRADICTED_DISPOSITION_CLASS}\n * stays a *total* mapping over {@link AdjudicationReasonCode}.\n */\ntype ContradictedDispositionClass = \"escalate\" | \"reroute_on_recurrence\" | \"retry_same_topology\";\n\n/**\n * Total mapping from every {@link AdjudicationReasonCode} to its CONTRADICTED disposition\n * class. Totality is compile-time enforced: adding a new reason code without classifying\n * it here is a type error, so a new code can never silently fall into an unintended\n * disposition. Codes that cannot in practice accompany a `CONTRADICTED` verdict (e.g.\n * `ALL_CHECKS_PASSED`, `RUN_NOT_TERMINAL`) still need a row; they take the conservative\n * default (`retry_same_topology`).\n */\nconst CONTRADICTED_DISPOSITION_CLASS: Record<AdjudicationReasonCode, ContradictedDispositionClass> = {\n\t// Part 3 §1: a scope violation is a safety signal that must never silently auto-retry.\n\tSCOPE_VIOLATION: \"escalate\",\n\t// Part 3 §1: recurring schema/shape drift means the topology/plan template itself may be\n\t// structurally wrong for the payload - reroute instead of retrying the same topology.\n\tSCHEMA_DRIFT: \"reroute_on_recurrence\",\n\tCONTENT_CHECK_FAILED: \"reroute_on_recurrence\",\n\t// Default CONTRADICTED row: same-topology retry (subject to the attempt budget).\n\tNO_EVIDENCE_ON_SUCCESS: \"retry_same_topology\",\n\tEMPTY_ARTIFACT_CONTENT: \"retry_same_topology\",\n\tTRACE_CHECK_FAILED: \"retry_same_topology\",\n\tTRACE_ERROR_SPAN: \"retry_same_topology\",\n\tMIN_ACTIONS_UNMET: \"retry_same_topology\",\n\tRUN_STATUS_UNPARSEABLE: \"retry_same_topology\",\n\tRUN_FETCH_FAILED: \"retry_same_topology\",\n\tMALFORMED_REQUEST: \"retry_same_topology\",\n\tRUN_NOT_TERMINAL: \"retry_same_topology\",\n\tEVIDENCE_EMPTY: \"retry_same_topology\",\n\tFAILURE_REPORTED: \"retry_same_topology\",\n\tALL_CHECKS_PASSED: \"retry_same_topology\",\n};\n\n/**\n * Part 1 §6's `next_action` vocabulary, restricted to the values Part 3 §1's projection\n * table actually produces (`'none'` covers the `CONFIRMED` row, which carries no\n * `next_action` of its own).\n */\nexport type NextActionKind = \"retry_same_topology\" | \"reroute\" | \"escalate\" | \"none\";\n\n/**\n * The projected disposition for a single record-level `AdjudicationResult` (Part 3 §1):\n * the Part 1 §2 state the packet should move towards, and which further-attempt behavior\n * (if any) that implies.\n */\nexport interface VerdictDisposition {\n\ttargetState: WorkPacketState;\n\tnextActionKind: NextActionKind;\n}\n\n/**\n * Projects a Part 2 record-level {@link AdjudicationResult} onto a Part 1 packet\n * disposition, per Part 3 §1's mapping table exactly:\n *\n * | verdict | condition | targetState | nextActionKind |\n * |---|---|---|---|\n * | `CONFIRMED` | - | `CONFIRMED` | `none` |\n * | `CORROBORATED-FAILURE` | - | `DECLINED` | `retry_same_topology` |\n * | `CONTRADICTED` | `reason_code` = `SCOPE_VIOLATION` | `DECLINED` | `escalate` |\n * | `CONTRADICTED` | `reason_code` ∈ {`SCHEMA_DRIFT`, `CONTENT_CHECK_FAILED`} AND `packet.retry_count >= 1` | `DECLINED` | `reroute` |\n * | `CONTRADICTED` | any other `reason_code` | `DECLINED` | `retry_same_topology` |\n * | `INDETERMINATE` | - | `DECLINED` | `escalate` |\n * | `VERIFIER-ERROR` | - | `DECLINED` | `escalate` |\n *\n * Branching is driven exclusively by the structured `reason_code`\n * ({@link CONTRADICTED_DISPOSITION_CLASS}); the free-text `reason` is never inspected, so\n * incidental wording in a check's human-readable explanation (e.g. \"scoped variable\")\n * can neither trigger a false escalation nor mask a real one.\n *\n * `VERIFIER-ERROR` vs. `ADJUDICATION_FAILED` (Part 3's dedicated section, restated here\n * because callers of this function must not conflate the two): `VERIFIER-ERROR` is a verdict\n * the OA *returned normally* - `adjudicate()` completed, produced a full\n * {@link AdjudicationResult}, and that result's own content says the OA's checks could not be\n * trusted for this record. This function only ever runs on such a completed result, so it\n * only ever needs to route `VERIFIER-ERROR` to `escalate` - never to a retry, and never\n * through `ADJUDICATION_FAILED`. `ADJUDICATION_FAILED` (Part 1 §2 state 9), by contrast, is\n * not a verdict at all: it is what happens when `adjudicate()` itself throws or times out and\n * *never returns a verdict in the first place* - there is no `AdjudicationResult` for this\n * function to project, because the mapping's input does not exist. That case is handled\n * separately by {@link runAdjudicationWithTimeout} (detecting the failure) and\n * {@link handleAdjudicationFailure} (deciding the packet's next state), never by this\n * function.\n *\n * Declared `async` for interface consistency with the rest of the verdict-handling pipeline\n * (all of whose other entry points are asynchronous); the projection logic itself is pure and\n * synchronous.\n */\nexport async function projectVerdictToDisposition(\n\tresult: AdjudicationResult,\n\tpacket: WorkPacket,\n): Promise<VerdictDisposition> {\n\tswitch (result.verdict) {\n\t\tcase \"CONFIRMED\":\n\t\t\treturn { targetState: \"CONFIRMED\", nextActionKind: \"none\" };\n\n\t\tcase \"CORROBORATED-FAILURE\":\n\t\t\treturn { targetState: \"DECLINED\", nextActionKind: \"retry_same_topology\" };\n\n\t\tcase \"CONTRADICTED\": {\n\t\t\tconst dispositionClass = CONTRADICTED_DISPOSITION_CLASS[result.reason_code];\n\t\t\tswitch (dispositionClass) {\n\t\t\t\tcase \"escalate\":\n\t\t\t\t\treturn { targetState: \"DECLINED\", nextActionKind: \"escalate\" };\n\t\t\t\tcase \"reroute_on_recurrence\":\n\t\t\t\t\t// \"Recurring\" is approximated as \"this packet has already had at least\n\t\t\t\t\t// one prior dispatch attempt\" (packet.retry_count >= 1), per Part 3 §1's\n\t\t\t\t\t// \"recurring across >= 2 attempts for this packet\" condition. A first\n\t\t\t\t\t// occurrence still takes the default same-topology retry.\n\t\t\t\t\tif (packet.retry_count >= 1) {\n\t\t\t\t\t\treturn { targetState: \"DECLINED\", nextActionKind: \"reroute\" };\n\t\t\t\t\t}\n\t\t\t\t\treturn { targetState: \"DECLINED\", nextActionKind: \"retry_same_topology\" };\n\t\t\t\tcase \"retry_same_topology\":\n\t\t\t\t\treturn { targetState: \"DECLINED\", nextActionKind: \"retry_same_topology\" };\n\t\t\t\tdefault: {\n\t\t\t\t\tconst exhaustive: never = dispositionClass;\n\t\t\t\t\tthrow new Error(`unhandled CONTRADICTED disposition class: ${String(exhaustive)}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tcase \"INDETERMINATE\":\n\t\t\treturn { targetState: \"DECLINED\", nextActionKind: \"escalate\" };\n\n\t\tcase \"VERIFIER-ERROR\":\n\t\t\t// Hard rule, not a default: VERIFIER-ERROR must never be\n\t\t\t// retry_same_topology or reroute. See the VERIFIER-ERROR vs.\n\t\t\t// ADJUDICATION_FAILED discussion above.\n\t\t\treturn { targetState: \"DECLINED\", nextActionKind: \"escalate\" };\n\t}\n}\n\n/**\n * Runs `adjudicate()` under both a timeout and a try/catch, per Part 1 §2 state 9 / Part 3's\n * \"ADJUDICATION_FAILED\" trigger condition. Returns `{ ok: true, result }` when `adjudicate()`\n * returns a verdict within `timeoutMs`; returns `{ ok: false, error }` if it throws, rejects,\n * or does not settle before the timeout - this is the ADJUDICATION_FAILED condition, and the\n * only way this function reports failure. It never lets a hung or throwing `adjudicate()`\n * call escape uncaught.\n *\n * Note the distinction from {@link projectVerdictToDisposition}'s `VERIFIER-ERROR` handling:\n * a `VERIFIER-ERROR` result here still comes back as `{ ok: true, result }` (a verdict was\n * produced), and must be routed through `projectVerdictToDisposition`, not through\n * {@link handleAdjudicationFailure}.\n */\nexport async function runAdjudicationWithTimeout(\n\trequest: AdjudicationRequest,\n\tclient: AdaptOrchClient,\n\tregistry: { get(kind: string): VerifierRegistryEntry },\n\ttimeoutMs: number,\n): Promise<{ ok: true; result: AdjudicationResult } | { ok: false; error: string }> {\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\ttry {\n\t\tconst result = await Promise.race([\n\t\t\tadjudicate(request, client, registry),\n\t\t\tnew Promise<never>((_resolve, reject) => {\n\t\t\t\ttimer = setTimeout(() => {\n\t\t\t\t\treject(new Error(`adjudicate() call timed out after ${timeoutMs}ms`));\n\t\t\t\t}, timeoutMs);\n\t\t\t}),\n\t\t]);\n\t\treturn { ok: true, result };\n\t} catch (error) {\n\t\treturn { ok: false, error: error instanceof Error ? error.message : String(error) };\n\t} finally {\n\t\tif (timer !== undefined) clearTimeout(timer);\n\t}\n}\n\n/**\n * Decides the packet's next state given an already-projected {@link VerdictDisposition}\n * (Part 1 §2/§4, Part 3 §1's `DECLINED -> {RETRY_QUEUED | CLOSED | ESCALATED}` branch). Pure\n * and side-effect free; does not itself call {@link applyTransition} from\n * `state-machine.ts` - callers apply the returned state via that function.\n *\n * - `nextActionKind === 'escalate'` always wins, regardless of remaining budget (Part 3 §1:\n * escalation \"takes priority over the attempt-budget check below, regardless of whether\n * budget remains\").\n * - `targetState === 'CONFIRMED'` returns `'CONFIRMED'` directly; the caller is responsible\n * for the separate `CONFIRMED -> CLOSED` transition (Part 1's success-close path), which is\n * not this function's concern.\n * - Otherwise (`retry_same_topology` or `reroute`), the per-packet attempt budget (Part 1 §4)\n * decides between `RETRY_QUEUED` (budget remains) and `CLOSED` (budget exhausted -\n * abandoned).\n */\nexport function decideNextTransition(packet: WorkPacket, disposition: VerdictDisposition): WorkPacketState {\n\tif (disposition.nextActionKind === \"escalate\") {\n\t\treturn \"ESCALATED\";\n\t}\n\n\tif (disposition.targetState === \"CONFIRMED\") {\n\t\treturn \"CONFIRMED\";\n\t}\n\n\treturn packet.retry_count < packet.attempt_budget.max_dispatch_attempts ? \"RETRY_QUEUED\" : \"CLOSED\";\n}\n\n/**\n * Decides the packet's next state after an `ADJUDICATION_FAILED` outcome (Part 1 §2 state 9;\n * see {@link runAdjudicationWithTimeout} for how that outcome is detected). This is the\n * *other* failure surface from `VERIFIER-ERROR` - there is no `AdjudicationResult` here, so\n * this function is never fed through {@link projectVerdictToDisposition} or\n * {@link decideNextTransition}.\n *\n * `adjudicationCallAttempts` / `maxAdjudicationCallAttempts` track a bounded counter for\n * retrying the `adjudicate()` *call itself* - distinct from, and never conflated with, the\n * packet's `retry_count` / `attempt_budget.max_dispatch_attempts` (Part 1 §7 notes this as a\n * separate persisted field, `adjudication_retry_count`, for exactly this purpose). Returns\n * `'UNDER_REVIEW'` (retry the call, against the already-pulled evidence) while the counter has\n * not been exhausted, else `'ESCALATED'` once it has.\n */\nexport function handleAdjudicationFailure(\n\tpacket: WorkPacket,\n\tadjudicationCallAttempts: number,\n\tmaxAdjudicationCallAttempts: number,\n): WorkPacketState {\n\tvoid packet;\n\treturn adjudicationCallAttempts < maxAdjudicationCallAttempts ? \"UNDER_REVIEW\" : \"ESCALATED\";\n}\n"]}