feat(invariants): implement package runtime checks

This commit is contained in:
Tianyi Cui
2026-07-20 00:38:37 +08:00
parent 36e99e737b
commit 941b0411d8
125 changed files with 2317 additions and 1161 deletions
@@ -109,6 +109,17 @@ describe('config validation', () => {
it('rejects a fractional maxInlineBytes at load', async () => {
await expect(setup({ maxInlineBytes: 1.5 })).rejects.toThrow(/non-negative integer/)
})
it('rejects a configured policy that omits its post-execute listener', async () => {
const ctx = new Context()
await ctx.plugin(SystemPrompt)
await ctx.plugin(ToolRegistry)
await expect(ctx.plugin({
name: 'spill-policy',
inject: ['tools'],
apply(_child: Context, _config: { maxInlineBytes?: number }) {},
}, { maxInlineBytes: 10 })).rejects.toThrow(/listener must exist exactly when maxInlineBytes is configured/)
})
})
describe('oversized plain-text replacement', () => {