test(sandbox-policy): record cache-safe policy context
This commit is contained in:
@@ -97,15 +97,23 @@ describe('parent-only override inheritance snapshot', () => {
|
||||
data: { mode: 'read-only', source: 'delegation' },
|
||||
})
|
||||
|
||||
const requestSystems = (content: string): string[] => content.trimEnd().split('\n').flatMap((line) => {
|
||||
const record = JSON.parse(line) as { type?: string; data?: { header?: { system?: unknown } } }
|
||||
const system = record.type === 'request/header' ? record.data?.header?.system : undefined
|
||||
return typeof system === 'string' ? [system] : []
|
||||
const runtimeContexts = (content: string): string[] => content.trimEnd().split('\n').flatMap((line) => {
|
||||
const record = JSON.parse(line) as {
|
||||
type?: string
|
||||
data?: { source?: { kind?: string; plugin?: string }; content?: Array<{ type?: string; text?: unknown }> }
|
||||
}
|
||||
if (record.type !== 'user/message'
|
||||
|| record.data?.source?.kind !== 'plugin'
|
||||
|| record.data.source.plugin !== '@deepseek-ai/dsh-system-prompt') return []
|
||||
return record.data.content?.flatMap(block => block.type === 'text' && typeof block.text === 'string' ? [block.text] : []) ?? []
|
||||
})
|
||||
for (const system of [...requestSystems(parent), ...requestSystems(child)]) {
|
||||
expect(system).toContain('The write and edit tools cannot modify files under this policy.')
|
||||
expect(system).not.toContain('one-shot bash commands')
|
||||
expect(system).not.toContain('terminal sessions')
|
||||
const policyContexts = [...runtimeContexts(parent), ...runtimeContexts(child)]
|
||||
expect(policyContexts).toHaveLength(2)
|
||||
for (const context of policyContexts) {
|
||||
expect(context).toContain('The write and edit tools cannot modify files in the standing mode.')
|
||||
expect(context).toContain('do not refuse a required modification from this standing mode alone')
|
||||
expect(context).not.toContain('one-shot bash commands')
|
||||
expect(context).not.toContain('terminal sessions')
|
||||
}
|
||||
|
||||
const context: NormalizeContext = { sessionIds: [sessionId, String(headerOf(child).id)], cwd }
|
||||
|
||||
Reference in New Issue
Block a user