Skip to content

Commit 96ecfe0

Browse files
chore(api): merge latest provenance update
# Conflicts: # apps/sim/app/api/mcp/serve/[serverId]/route.ts # apps/sim/lib/copilot/tools/handlers/workflow/mutations.ts
2 parents 6b336a8 + 5dbc342 commit 96ecfe0

31 files changed

Lines changed: 243 additions & 66 deletions

apps/sim/app/api/guardrails/validate/route.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ describe('POST /api/guardrails/validate', () => {
244244
expect(res.status).toBe(200)
245245
expect(mockImportProvenance).toHaveBeenCalledWith(provenance, 'secret value', ['input'], {
246246
trusted: true,
247+
origin: 'guardrailsRoute.inputProvenance',
247248
})
248249
})
249250

apps/sim/app/api/guardrails/validate/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
267267
provenanceInspection.value,
268268
inputStr,
269269
['input'],
270-
{ trusted: true }
270+
{ trusted: true, origin: 'guardrailsRoute.inputProvenance' }
271271
)
272272
).success
273273
: true

apps/sim/app/api/mcp/serve/[serverId]/route.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,10 @@ async function projectWorkflowToolOutput(
215215
}
216216

217217
const registry = new ResolvedSecretTraceRegistry([], scope)
218-
const imported = await registry.importProvenance(provenance, { trusted: true })
218+
const imported = await registry.importProvenance(provenance, {
219+
trusted: true,
220+
origin: 'mcpServe.workflowCrossing',
221+
})
219222
if (!imported || !registry.isComplete()) {
220223
throw new Error('MCP workflow execution provenance could not be restored')
221224
}

apps/sim/app/api/providers/route.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ describe('POST /api/providers', () => {
208208
)
209209

210210
expect(res.status).toBe(200)
211-
expect(mockImportProvenance).toHaveBeenCalledWith(provenance, { trusted: true })
211+
expect(mockImportProvenance).toHaveBeenCalledWith(provenance, {
212+
trusted: true,
213+
origin: 'providersRoute.requestProvenance',
214+
})
212215
})
213216

214217
it('projects legacy private prompt provenance on the provider-facing copy', async () => {

apps/sim/app/api/providers/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
272272
const provenanceReady =
273273
await providerRuntimeContext.resolvedSecretTraceRegistry.importProvenance(
274274
provenanceInspection.value,
275-
{ trusted: true }
275+
{ trusted: true, origin: 'providersRoute.requestProvenance' }
276276
)
277277
if (!provenanceReady || !providerRuntimeContext.resolvedSecretTraceRegistry.isComplete()) {
278278
return NextResponse.json(

apps/sim/app/api/workflows/[id]/log/route.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ export const POST = withRouteHandler(
144144
if (trustedProvenance === undefined) {
145145
resolvedSecretTraceRegistry.markIncomplete()
146146
} else {
147-
await resolvedSecretTraceRegistry.importProvenance(trustedProvenance, { trusted: true })
147+
await resolvedSecretTraceRegistry.importProvenance(trustedProvenance, {
148+
trusted: true,
149+
origin: 'workflowLogRoute.trustedProvenance',
150+
})
148151
}
149152
loggingSession.setResolvedSecretTraceRegistry(resolvedSecretTraceRegistry)
150153

apps/sim/executor/handlers/mothership/mothership-handler.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ describe('MothershipBlockHandler', () => {
293293
content: 'raw secret remains functional',
294294
__resolvedSecretTraceProvenance: undefined,
295295
}),
296-
{ trusted: true }
296+
{ trusted: true, origin: 'mothership.payloadCrossing' }
297297
)
298298
expect(registry.markIncomplete).not.toHaveBeenCalled()
299299
expect(result).toMatchObject({ content: 'raw secret remains functional' })
@@ -519,7 +519,7 @@ describe('MothershipBlockHandler', () => {
519519
error: 'secret-backed failure',
520520
__resolvedSecretTraceProvenance: undefined,
521521
}),
522-
{ trusted: true }
522+
{ trusted: true, origin: 'mothership.payloadCrossing' }
523523
)
524524
expect(context.errorResolvedSecretTraceRegistry).toBeDefined()
525525
expect(context.errorResolvedSecretTraceRegistry).not.toBe(context.resolvedSecretTraceRegistry)
@@ -557,7 +557,7 @@ describe('MothershipBlockHandler', () => {
557557
error: 'secret-backed failure',
558558
__resolvedSecretTraceProvenance: undefined,
559559
}),
560-
{ trusted: true }
560+
{ trusted: true, origin: 'mothership.payloadCrossing' }
561561
)
562562
expect(registry.markIncomplete).not.toHaveBeenCalled()
563563
expect(context.errorResolvedSecretTraceRegistry).toBeDefined()
@@ -601,7 +601,7 @@ describe('MothershipBlockHandler', () => {
601601
content: 'unchanged',
602602
__resolvedSecretTraceProvenance: undefined,
603603
}),
604-
{ trusted: true }
604+
{ trusted: true, origin: 'mothership.payloadCrossing' }
605605
)
606606
expect(registry.markIncomplete).not.toHaveBeenCalled()
607607
expect(JSON.stringify(result.execution.output)).not.toContain('__resolvedSecretTraceProvenance')

apps/sim/executor/handlers/mothership/mothership-handler.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,10 @@ async function consumeMothershipProvenance(
378378

379379
if (!registry) return false
380380

381-
const imported = await registry.importProvenanceForValue(provenance, payload, { trusted: true })
381+
const imported = await registry.importProvenanceForValue(provenance, payload, {
382+
trusted: true,
383+
origin: 'mothership.payloadCrossing',
384+
})
382385
if (!imported) throw new Error('Mothership response provenance metadata is invalid')
383386
return true
384387
}

apps/sim/executor/handlers/workflow/workflow-handler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ export class WorkflowBlockHandler implements BlockHandler {
459459
await childResolvedSecretTraceRegistry.importProvenance(crossingProvenance, {
460460
trusted: true,
461461
anonymous: true,
462+
origin: 'workflowHandler.childCrossing',
462463
})
463464
}
464465
// Custom-block children authenticate internal tool calls as the source
@@ -720,6 +721,7 @@ export class WorkflowBlockHandler implements BlockHandler {
720721
await ctx.resolvedSecretTraceRegistry.importProvenance(crossingProvenance, {
721722
trusted: true,
722723
anonymous: true,
724+
origin: 'workflowHandler.parentCrossing',
723725
})
724726
}
725727
return exposedOutput

apps/sim/executor/utils/resolved-secret-projection-refusal.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,35 @@ describe('refuseResolvedSecretProjection', () => {
195195
expect(refusalRecords()).toHaveLength(3)
196196
})
197197

198+
it('names the importer that condemned the run, through the fork and merge that hid it', async () => {
199+
const parent = new ResolvedSecretTraceRegistry([], scope)
200+
const fork = parent.forkForToolCall()
201+
await fork.importCrossingProvenance(
202+
{ version: 1, complete: false, entries: [], scope },
203+
{ rows: [] },
204+
{ trusted: true, origin: 'tool.table_query_rows' }
205+
)
206+
parent.mergeToolCallRegistry(fork)
207+
mockLogger.error.mockClear()
208+
mockLogger.warn.mockClear()
209+
210+
expect(() =>
211+
refuseResolvedSecretProjection({
212+
site: 'router.contextModelInput',
213+
message: 'Router model input could not be safely projected',
214+
registry: parent,
215+
inputPath: 'context,routes',
216+
})
217+
).toThrow()
218+
219+
expect(refusalRecords()[0][1]).toEqual(
220+
expect.objectContaining({
221+
reason: 'source-provenance-incomplete',
222+
origins: ['tool.table_query_rows'],
223+
})
224+
)
225+
})
226+
198227
it('records no secret material', () => {
199228
const registry = new ResolvedSecretTraceRegistry(
200229
[{ name: 'API_KEY', plaintext: 'super-secret-value', encryptedValue: 'encrypted' }],

0 commit comments

Comments
 (0)