MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / runConditionsScenario

Function runConditionsScenario

scripts/gen-governance-audit-examples.ts:131–195  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

129}
130
131async function runConditionsScenario(): Promise<{ trail: ToolCall[]; audit: Record<string, unknown> }> {
132 const server = createTrainingAgentServer(DEFAULT_CTX);
133 const t = tenant('nova-mortgage.example');
134 const planId = 'plan_2027_nova_mortgage';
135 const trail: ToolCall[] = [];
136
137 // Annex III industry: mortgage/lending. Auto-flips human_review_required.
138 trail.push({ tool: 'sync_plans', args: { plan_id: planId }, result: (await callTool(server, 'sync_plans', {
139 ...t,
140 plans: [{
141 plan_id: planId,
142 brand: { domain: 'nova-mortgage.example', name: 'Nova Mortgage', industry: 'mortgage' },
143 objectives: 'Refinance awareness across approved markets.',
144 budget: { total: 250000, currency: 'USD', reallocation_threshold: 25000 },
145 flight: PLAN_FLIGHT,
146 channels: { allowed: ['olv', 'display'] },
147 countries: ['US'],
148 policy_categories: ['fair_lending'],
149 mode: 'enforce',
150 }],
151 })).result });
152
153 trail.push({ tool: 'check_governance:intent', args: {}, result: (await callTool(server, 'check_governance', {
154 ...t,
155 plan_id: planId,
156 binding: 'proposed',
157 caller: 'https://orchestrator.pinnacle-media.example',
158 tool: 'get_products',
159 })).result });
160
161 trail.push({ tool: 'check_governance:execution', args: { tool: 'create_media_buy' }, result: (await callTool(server, 'check_governance', {
162 ...t,
163 plan_id: planId,
164 binding: 'committed',
165 caller: 'https://ads.seller-a.example',
166 tool: 'create_media_buy',
167 purchase_type: 'media_buy',
168 payload: {
169 total_budget: 80000,
170 currency: 'USD',
171 channels: ['olv'],
172 flight: PLAN_FLIGHT,
173 },
174 })).result });
175
176 const exec = trail[trail.length - 1].result as { governance_context?: string };
177 if (exec.governance_context) {
178 trail.push({ tool: 'report_plan_outcome', args: {}, result: (await callTool(server, 'report_plan_outcome', {
179 ...t,
180 plan_id: planId,
181 governance_context: exec.governance_context,
182 outcome: 'completed',
183 purchase_type: 'media_buy',
184 committed_budget: 80000,
185 })).result });
186 }
187
188 const auditCall = await callTool(server, 'get_plan_audit_logs', {

Callers 1

mainFunction · 0.85

Calls 3

tenantFunction · 0.85
callToolFunction · 0.70

Tested by

no test coverage detected